使用 PlistBuddy 获取应用程序版本返回“CFBundleShortVersionString 不存在”

Emr*_*der 5 terminal plist ios

我知道这是一个简单而愚蠢的问题,但我找不到为什么会出错。我想在获取文件后打印项目的应用程序版本xcarchive。我正在用PlistBuddy这个。

/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" /build/My_Project.xcarchive/Info.plist 
Run Code Online (Sandbox Code Playgroud)

这段代码返回

打印:条目“CFBundleShortVersionString”不存在

但是,我可以成功打印“ApplicationProperties”或整个 plist 文件。可能是什么问题?

tah*_*ath 3

CFBundleShortVersionString属性存储在ApplicationProperties字典中,PlistBuddy 帮助说:

Entries consist of property key names delimited by colons.  Array items
are specified by a zero-based integer index.  Examples:
    :CFBundleShortVersionString
    :CFBundleDocumentTypes:2:CFBundleTypeExtensions
Run Code Online (Sandbox Code Playgroud)

因此,为了获取该值,您需要运行以下命令:

/usr/libexec/PlistBuddy -c "Print ApplicationProperties:CFBundleShortVersionString" /build/My_Project.xcarchive/Info.plist 
Run Code Online (Sandbox Code Playgroud)