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

前端 未结 13 795
一个人的身影
一个人的身影 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:47

    I believe you can do this using a way that's similar to what I describe in this answer (based on this post).

    First, you can make VersionValue a variable within Xcode by renaming it to ${VERSIONVALUE}. Create a file named versionvalue.xcconfig and add it to your project. Go to your application target and go to the Build settings for that target. I believe that you need to add VERSIONVALUE as a user-defined build setting. In the lower-right-corner of that window, change the Based On value to "versionvalue".

    Finally, go to your target and create a Run Script build phase. Inspect that Run Script phase and paste in your script within the Script text field. For example, my script to tag my BUILD_NUMBER setting with the current Subversion build is as follows:

    REV=`/usr/bin/svnversion -nc ${PROJECT_DIR} | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
    echo "BUILD_NUMBER = $REV" > ${PROJECT_DIR}/buildnumber.xcconfig
    

    This should do the trick of replacing the variable when these values change within your project.

提交回复
热议问题