【FAQ】defaults 提示 domain Info.plist does not exists.

【問題】在使用 defaults 命令修改 Info.plist 文件時,提示 domain Info.plist does not exists. 可是文件明明是存在的。

使用命令爲:defaults write Info.plist CFBundleVersion 3.0.0

【分析】man defaults,有一段關於 filepath 的描述:

filepath  Domains may also be specified as a path to an arbitrary plist file, with or without the '.plist' extension. For example:
    defaults read ~/Library/Containers/com.apple.TextEdit/Data/Library/Preferences/com.apple.TextEdit.plist
normally gives the same result as the two previous examples.  In the following example:
    defaults write ~/Desktop/TestFile foo bar
will write the key 'foo' with the value 'bar' into the plist file 'TestFile.plist' that is on the user's desktop. If the file does not exist, it will be created. If it does exist, the key-value pair will be added, overwriting the value of 'foo' if it already existed.
WARNING: The defaults command will be changed in an upcoming major release to only operate on preferences domains. General plist manipulation utilities will be folded into a different command-line program.

【解決】參考示例,將 path 改成絕對路徑問題就解決了:

使用命令爲:defaults write /dir/to/my/Info.plist CFBundleVersion 3.0.0

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章