在 Xcode 中插入 Subversion 修订号 [英] Insert Subversion revision number in Xcode

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

问题描述

我想将当前的 Subversion 修订号(由 svnversion 报告)插入到我的 Xcode 项目中.我设法将修订号插入到 $PROJECT_DIRInfo.plist 中,但这不是一个好的解决方案,因为该文件是版本化的.我尝试将修订版插入到构建目录中的 Info.plist 中,但随后在代码签名阶段出现错误(这是一个 iPhone 应用程序).

I would like to insert the current Subversion revision number (as reported by svnversion) into my Xcode project. I managed to insert the revision number into the Info.plist in the $PROJECT_DIR, but this is not a good solution, since the file is versioned. I tried to insert the revision into the Info.plist in the build directory, but then I get an error during the code signing phase (this is an iPhone application).

是否有一种简单的方法可以使用一些构建文件将修订号输入到应用程序中,以便更改的修订版不会更改版本化文件?我想也许我可以创建一个临时源文件来链接其他文件并提供一个函数来获取修订号.但我不知道该怎么做.

Is there a simple way to get the revision number into the application using some build files, so that the changing revision does not change versioned files? I thought maybe I could create a temporary source file that would link with the others and provide a function to get the revision number. But I don’t know how to do that.

我对其他解决方案不太感兴趣,即.agvtool.我想要的是应用程序可用的修订号,没有太多的魔力.

I am not much interested in other solutions, ie. the agvtool. All I want is the revision number available to the application, without too much magic.

推荐答案

有一个更简单的解决方案:使用 PlistBuddy,包含在 Leopard 的 /usr/libexec/PlistBuddy 中.有关详细信息,请参阅我对相关 SO 问题的回答.

There's a much simpler solution: using PlistBuddy, included at /usr/libexec/PlistBuddy in Leopard. See my answer to a related SO question for details.

PlistBuddy 可以在 Xcode 中的 Run Script 构建阶段使用,并且只能用于影响已处理的 plist 文件.只需将它放在复制资源阶段之后,您甚至不必每次都清理目标以使其运行.您甚至不必将该值打印到头文件并使 SVN 忽略它.

PlistBuddy can be used in a Run Script build phase from within Xcode, and can be used to only affect the processed plist file. Just put it after the Copy Resources phase, and you don't even have to clean the target for it to run each time. You don't even have to print the value to a header file and make SVN ignore it, either.

echo -n ${TARGET_BUILD_DIR}/${INFOPLIST_PATH} \
    | xargs -0 /usr/libexec/PlistBuddy -c "Set :CFBundleVersion `svnversion -n`"

假设您在代码签名之前添加构建阶段,您的 plist 应该使用替换值进行签名.

Assuming you add the build phase before code signing occurs, your plist should be signed with the substituted value.

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

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