如果我使用 PlistBuddy 修改 root 拥有的 plist,该命令会以退出代码 0 完成。但是,plist 不会被修改。当我使用 sudo 重新运行该命令时,plist 会按预期进行修改。
这是 PlistBuddy 中的错误吗?这给我带来了一些麻烦 Appium configuration script .
我正在使用这个命令:
/usr/libexec/PlistBuddy -c "Add :TestTestTest dict" "$SOME_PLIST_PATH" || echo "failed"
这是完整的 session :
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"
}
最佳答案
PlistBuddy 没有很好的文档记录(我在developer.apple.com 上找不到它的手册页),因此 Apple 很可能希望使用它的高级用户(和开发人员)简单地知道 sudo
当弄乱 root 拥有的 plist 文件时需要调用。
我建议在 bugreporter.apple.com 上提交增强请求,并建议他们向 PlistBuddy 添加“-v
”(用于详细)选项,以打印添加或删除的结果。
目前,您所能做的就是打印出您尝试设置的设置,如果不起作用,则设置失败。
关于macos - PlistBuddy 默默地失败了——bug?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34561340/