XCode 4:在Xcode中插入Subversion版本号 [英] XCode 4:Insert Subversion revision number in Xcode

查看:127
本文介绍了XCode 4:在Xcode中插入Subversion版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,这与这个问题非常相关,但我认为对于XCode 3,该问题得到了充分的回答。不确定是否应该合并。

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.

所以 - 使用那里的类似指令,我一直有很好的效果,即将编号编码到存档的.ipa文件中,以便Organizer显示类似1.0的版本.3281(其中3281是通过以下构建脚本附加到我的iOS目标的修订版):

So - Using similar instructions from there, I've long had the nice effect of having build numbers encoded into archived .ipa files, such that Organizer shows versions like "1.0.3281" (where 3281 is the revision via the below build script attached to my iOS target):

REV=`svnversion -nc | /usr/bin/sed -e 's/^[^:]*://;s/[A-Za-z]//'`
echo "REV=$REV"
echo "#define kRevisionNumber @\"$REV\"" > ${PROJECT_DIR}/revision.h
echo "INFOPLIST_PATH=${INFOPLIST_PATH}"

BASEVERNUM=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "${INFOPLIST_FILE}" | sed 's/,/, /g'`
echo "BASEVERNUM=$BASEVERNUM"
PLISTARG1="Set :CFBundleVersion $BASEVERNUM.$REV"
echo "PLISTARG1=$PLISTARG1"

/usr/libexec/PlistBuddy -c "$PLISTARG1" "${TARGET_BUILD_DIR}"/${INFOPLIST_PATH}

但是,XCode 4(我已经爱上了)显然需要进行一些调整,因为这种神奇的方式只能起作用。以下是上述脚本的结果。

However, XCode 4 (which I've since come to love) clearly needs some tweaking, as this magic only sort-of works. Here is the result of the scripts above.

REV=3281
INFOPLIST_PATH=Foo.app/Info.plist
BASEVERNUM=1.0
PLISTARG1=Set :CFBundleVersion 1.0.3281

我可以通过查看〜/ Library /.../ Foo.app/Info.plist看是的,确实更新了正确的版本:

And I can see by looking in ~/Library/.../Foo.app/Info.plist that yes, it did update the right version:

<key>CFBundleVersion</key>
<string>1.0.3281</string>

显然有一个附加文件需要更新..也许在.xcarchive?关于在哪里钻取的第一个建议?

So clearly there is an additional file needing updating.. perhaps in the .xcarchive? Any suggestions on where to drill into first?

推荐答案

我不确定存档角度,但以下内容适用于Xcode 4(即我的应用是在组织者中列为Foo 1.0.307)

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. 手动设置 CFBundleShortVersionString (又名Bundle versions string,short) info.plist 中的值到 major.minor 内部版本号(例如1.0)

  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)

使用以下脚本为项目添加运行脚本构建阶段

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}"


  • 清理和构建(Clean步骤强制Xcode重新处理info.plist)。

  • Clean and build (the Clean step forces Xcode to reprocess the info.plist).

    BTW你也可以使用 [[NSBundle mainBundle] objectForInfoDictionaryKey:@来访问你应用程序内的这个版本号(例如在'about'页面上) CFBundleVersion]

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

    这篇关于XCode 4:在Xcode中插入Subversion版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆