Amitg2k12
Amitg2k12

Reputation: 3805

Info.plist | Modify Version String

Our OSX Application running on have some modules which are running on other platform too, i.e. most of the part are ported to different platform and some are common across all platform,

When come to version no, to be consistent with the other platform port, we need to maintain a common version say, AppVersion.h which has the version string.

Now to show on the UI , i need to copy the same version string from AppVersion.h file to Info.plist

Are there any workaround for the same, i.e. run some pre-build script which reads the version string and update the info.plist.

Thanks in advance.

Upvotes: 1

Views: 1030

Answers (1)

Steven Fisher
Steven Fisher

Reputation: 44876

Absolutely! This is what I use as a build phase, after the resource copy. I break down the problem a bit because this is part of a much larger script.

#!/bin/sh
export PlistBuddy="/usr/libexec/PlistBuddy"
# TODO: Get OUR_VERSION here.
export appPlist="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_FOLDER_PATH}/Info.plist"
$PlistBuddy $appPlist -c "set :CFBundleShortVersionString '$OUR_VERSION'"
$PlistBuddy $appPlist -c "set :CFBundleVersion '$OUR_VERSION'"

As to how to get OUR_VERSION? I leave that open to you. In my case, I simply grepped the file in the script. For me, this was an xcconfig but for you it'll be the header. If you've got command line experience, you might have a better way to extract the symbol meaning from the .h file.

Note that this sets CFBundleShortVersionString (the user-visible version) and CFBundleVersion (the internal version) to the same value. That's probably what you want. If not, fix that. :)

Upvotes: 5

Related Questions