首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PlistBuddy无声地失败了- bug?

PlistBuddy无声地失败了- bug?
EN

Stack Overflow用户
提问于 2016-01-02 00:04:45
回答 2查看 544关注 0票数 2

如果我使用PlistBuddy来修改根用户拥有的plist,则命令将使用退出代码0完成。然而,plist没有被修改。当我用sudo重新运行命令时,plist会按预期进行修改。

这是PlistBuddy中的一个bug吗?它在Appium配置脚本上给我带来了一些麻烦。

我使用这个命令:

代码语言:javascript
复制
/usr/libexec/PlistBuddy -c "Add :TestTestTest dict" "$SOME_PLIST_PATH" || echo "failed"

以下是一次完整的会议:

代码语言:javascript
复制
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"
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-02 00:51:22

PlistBuddy没有很好的文档(我在developer.apple.com上找不到它的手册页),所以苹果很可能希望使用它的高级用户(和开发人员)知道,在处理根拥有的plist文件时,需要调用sudo

我建议在bugreporter.apple.com上提交一个增强请求,并建议他们在PlistBuddy中添加一个"-v“(用于详细)选项,以打印添加或删除的结果。

现在,您所能做的就是打印出您试图设置的设置,如果设置不工作,则设置失败。

票数 3
EN

Stack Overflow用户

发布于 2018-03-28 10:10:45

在我发现我没有对我的entitlements.plist的写访问权之前,我也一直在默默地失败,所以请确保您始终具有对正在编辑的.plist的写访问权限。

另一种选择是使用plutil,它不会默默地失败。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34561340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档