天天看點

在腳本中操作plist檔案

終端輸入:

/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" /Users/achen/Desktop/testBundle/testBundle/Info.plist

/usr/libexec/PlistBuddy 是系統工具的指令,用于操作plist檔案。

-c "Print CFBundleIdentifier" ,這裡的CFBundleIdentifier 可以被替換為其他鍵值。

/Users/achen/Desktop/testBundle/testBundle/Info.plist 是plist的檔案路徑。

實際我們在寫腳本的時候可以像下面這麼寫:

BUNDLE_Identifier=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "${InfoPath}")

${InfoPath} 是plist檔案的路徑, 需要先擷取到。

繼續閱讀