Search code examples
iosxcodeinfo-plist

What's the raw name of "Bundle versions string, short"?


To concatenate the version number to the "Bundle display name" parameter in Info.plist I'd like to know the raw name of "Bundle versions string, short".


Solution

  • From Core Foundation Keys:

    CFBundleShortVersionString: “Bundle versions string, short” / (Localizable) The release-version-number string for the bundle. See CFBundleShortVersionString for details.

    You could also right-click the row in Xcode and click "Show Raw Keys/Values".


    To update the CFBundleName automatically you have to create a script that is doing so in the Build Phases tab of your target. (Click the project name in the left sidebar, click the corresponding target name under "Targets", go to the "Build Phases" tab, click the "+"-sign in the upper left corner and choose "New Run Script Phase")

    bundleVersionString=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$INFOPLIST_FILE")
    /usr/libexec/PlistBuddy -c "Set :CFBundleName $PRODUCT_NAME $bundleVersionString" "$INFOPLIST_FILE"
    

    Give the new "Run Script" an appropriate name by double-clicking the name and change it to something like "Append Version to Product Name". It might also be possible that the script must be run before "Copy Bundle Resources".