Emre Önder
Emre Önder

Reputation: 2537

Get App Version with PlistBuddy returns "CFBundleShortVersionString does not exist"

I know this is an easy and silly question but I can't find why I'm getting error. I want to print the app version of a project after getting xcarchive file. I'm using PlistBuddy for that.

/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" /build/My_Project.xcarchive/Info.plist 

This code returns

Print: Entry, "CFBundleShortVersionString", Does Not Exist

However, I can successfully print "ApplicationProperties" or whole plist file. What can be the problem?

Upvotes: 5

Views: 4031

Answers (1)

tahavath
tahavath

Reputation: 234

The CFBundleShortVersionString property is stored inside ApplicationProperties dictionary, and PlistBuddy help says:

Entries consist of property key names delimited by colons.  Array items
are specified by a zero-based integer index.  Examples:
    :CFBundleShortVersionString
    :CFBundleDocumentTypes:2:CFBundleTypeExtensions

So, in order to get this value you need to run following command:

/usr/libexec/PlistBuddy -c "Print ApplicationProperties:CFBundleShortVersionString" /build/My_Project.xcarchive/Info.plist 

Upvotes: 3

Related Questions