如果我使用PlistBuddy来修改根用户拥有的plist,则命令将使用退出代码0完成。然而,plist没有被修改。当我用sudo重新运行命令时,plist会按预期进行修改。
这是PlistBuddy中的一个bug吗?它在Appium配置脚本上给我带来了一些麻烦。
我使用这个命令:
/usr/libexec/PlistBuddy -c "Add :TestTestTest dict" "$SOME_PLIST_PATH" || echo "failed"以下是一次完整的会议:
tba $ echo "$SOME_PLIST_PATH"
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Developer/Library/LaunchDaemons/com.apple.instruments.deviceservice.plist
tba $ ll "$SOME_PLIST_PATH"
-rw-r--r-- 1 root wheel 1.1K Jan 1 15:51 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Developer/Library/LaunchDaemons/com.apple.instruments.deviceservice.plist
tba $ plutil -p "$SOME_PLIST_PATH"
{
"Program" => "/Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub"
"EnvironmentVariables" => {
"LIB_PATH" => "/usr/local/lib/node_modules/appium//node_modules/appium-instruments/thirdparty/iwd7/"
"DYLD_INSERT_LIBRARIES" => "/usr/local/lib/node_modules/appium//node_modules/appium-instruments/thirdparty/iwd7/DTMobileISShim.dylib"
}
"JetsamProperties" => {
"JetsamMemoryLimit" => 0
}
"POSIXSpawnType" => "Adaptive"
"MachServices" => {
"com.apple.instruments.deviceservice.xpc" => 1
"com.apple.instruments.deviceservice.lockdown" => 1
}
"EnableTransactions" => 1
"Label" => "com.apple.instruments.deviceservice"
}
tba $ /usr/libexec/PlistBuddy -c "Add :TestTestTest dict" "$SOME_PLIST_PATH" || echo "failed"
tba $ plutil -p "$SOME_PLIST_PATH"
{
"Program" => "/Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub"
"EnvironmentVariables" => {
"LIB_PATH" => "/usr/local/lib/node_modules/appium//node_modules/appium-instruments/thirdparty/iwd7/"
"DYLD_INSERT_LIBRARIES" => "/usr/local/lib/node_modules/appium//node_modules/appium-instruments/thirdparty/iwd7/DTMobileISShim.dylib"
}
"JetsamProperties" => {
"JetsamMemoryLimit" => 0
}
"POSIXSpawnType" => "Adaptive"
"MachServices" => {
"com.apple.instruments.deviceservice.xpc" => 1
"com.apple.instruments.deviceservice.lockdown" => 1
}
"EnableTransactions" => 1
"Label" => "com.apple.instruments.deviceservice"
}
tba $ sudo /usr/libexec/PlistBuddy -c "Add :TestTestTest dict" "$SOME_PLIST_PATH" || echo "failed"
Password:
tba $ plutil -p "$SOME_PLIST_PATH"
{
"Program" => "/Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub"
"EnvironmentVariables" => {
"LIB_PATH" => "/usr/local/lib/node_modules/appium//node_modules/appium-instruments/thirdparty/iwd7/"
"DYLD_INSERT_LIBRARIES" => "/usr/local/lib/node_modules/appium//node_modules/appium-instruments/thirdparty/iwd7/DTMobileISShim.dylib"
}
"JetsamProperties" => {
"JetsamMemoryLimit" => 0
}
"POSIXSpawnType" => "Adaptive"
"TestTestTest" => {
}
"MachServices" => {
"com.apple.instruments.deviceservice.xpc" => 1
"com.apple.instruments.deviceservice.lockdown" => 1
}
"EnableTransactions" => 1
"Label" => "com.apple.instruments.deviceservice"
}发布于 2016-01-02 00:51:22
PlistBuddy没有很好的文档(我在developer.apple.com上找不到它的手册页),所以苹果很可能希望使用它的高级用户(和开发人员)知道,在处理根拥有的plist文件时,需要调用sudo。
我建议在bugreporter.apple.com上提交一个增强请求,并建议他们在PlistBuddy中添加一个"-v“(用于详细)选项,以打印添加或删除的结果。
现在,您所能做的就是打印出您试图设置的设置,如果设置不工作,则设置失败。
发布于 2018-03-28 10:10:45
在我发现我没有对我的entitlements.plist的写访问权之前,我也一直在默默地失败,所以请确保您始终具有对正在编辑的.plist的写访问权限。
另一种选择是使用plutil,它不会默默地失败。
https://stackoverflow.com/questions/34561340
复制相似问题