Mik*_*ner 5 macos xcode command-line nsuserdefaults xcode-server
我的目标之一是使用 defaults 命令读取属性列表的外部构建工具。
当机器人运行该工具时,defaults 命令无法找到指定的默认值:
defaults read /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString
> The domain/default pair of (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version, CFBundleShortVersionString) does not exist
Run Code Online (Sandbox Code Playgroud)
从普通用户的帐户运行相同的命令可以正常工作:
defaults read /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString
> 7.1
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,它不适用于 _teamsserver 用户:
sudo -u _teamsserver defaults read /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString
> The domain/default pair of (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version, CFBundleShortVersionString) does not exist
Run Code Online (Sandbox Code Playgroud)
……这就是机器人无法构建的原因。
知道为什么这不起作用吗?
谢谢。
尝试使用 PlistBuddy 代替:
/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/version.plist
Run Code Online (Sandbox Code Playgroud)
请注意,从 10.9 开始,您不应该使用 PlistBuddy 来修改首选项文件。苹果添加了一个缓存系统来提高用户首选项的性能,并且它不会看到直接对首选项文件进行的更改。在这种情况下,请使用“defaults”命令,该命令使用正确的 API 来更改首选项。我的猜测是,当尝试使用 sudo 的“defaults”命令来访问通用 plist 时,首选项缓存系统也可能是造成问题的原因。
| 归档时间: |
|
| 查看次数: |
354 次 |
| 最近记录: |