XCode 4:Insert Subversion revision number in Xcode

后端 未结 3 2222
眼角桃花
眼角桃花 2021-02-11 08:34

Yes, this is very related to this question, yet I think that question is adequately answered for XCode 3. Not sure if this should be merged or not.

So - Using similar i

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-11 09:25

    I'm not sure about the archive angle, but the following is working for me in Xcode 4 (i.e. my app is listed in organiser as Foo 1.0.307)

    1. Manually set the CFBundleShortVersionString (aka "Bundle versions string, short") value in your info.plist to your major.minor build number (e.g. 1.0)

    2. Add a 'run script' build phase to your project with the following script

      REV=`svnversion -nc | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
      BASEVERNUM=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "${INFOPLIST_FILE}"`
      /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BASEVERNUM.$REV" "${INFOPLIST_FILE}"
      
    3. Clean and build (the Clean step forces Xcode to reprocess the info.plist).

    BTW you can also access this version number inside your app (e.g. on your 'about' page) using [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]

提交回复
热议问题