How can I display the application version revision in my application's settings bundle?

前端 未结 13 819
一个人的身影
一个人的身影 2020-11-29 15:20

I would like to include the application version and internal revision, something like 1.0.1 (r1243), in my application\'s settings bundle.

The Root.plist file contai

13条回答
  •  感动是毒
    2020-11-29 15:37

    There is another solution that can be much simpler than either of the previous answers. Apple bundles a command-line tool called PlistBuddy inside most of its installers, and has included it in Leopard at /usr/libexec/PlistBuddy.

    Since you want to replace VersionValue, assuming you have the version value extracted into $newVersion, you could use this command:

    /usr/libexec/PlistBuddy -c "Set :VersionValue $newVersion" /path/to/Root.plist
    

    No need to fiddle with sed or regular expressions, this approach is quite straightforward. See the man page for detailed instructions. You can use PlistBuddy to add, remove, or modify any entry in a property list. For example, a friend of mine blogged about incrementing build numbers in Xcode using PlistBuddy.

    Note: If you supply just the path to the plist, PlistBuddy enters interactive mode, so you can issue multiple commands before deciding to save changes. I definitely recommend doing this before plopping it in your build script.

提交回复
热议问题