增加内部版本号的更好方法? [英] Better way of incrementing build number?

查看:29
本文介绍了增加内部版本号的更好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 shell 脚本作为我的 Xcode 构建过程的一部分来增加 plist 文件中的构建号,但是它使 Xcode 4.2.1 频繁崩溃(关于目标的错误不属于项目;我猜 plist 文件的更改在某种程度上使 Xcode 感到困惑).

I have been using a shell script as part of my Xcode build process to increment the build number within the plist file, however it's making Xcode 4.2.1 crash frequently (with an error about the target not belonging to a project; I'm guessing the changing of the plist file is confusing Xcode in some way).

shell 脚本这样做是为了当文件比 plist 文件更新时,构建号仅由 agvtool 递增(因此只是构建不会递增值):

The shell script did this so that the build number is only incremented by agvtool when a file is newer than the plist file (so just building didn't increment the value):

if [ -n "`find ProjDir -newer ProjDir/Project-Info.plist`" ]; then agvtool -noscm next-version -all; else echo "Version not incremented"; fi

有没有办法在不破坏 Xcode 的情况下增加内部版本号(在 plist 文件中或其他任何地方)?

Is there a way to increment the build number (in the plist file, or anywhere else) that doesn't break Xcode?

最终编辑:我现在使用刚刚在 github.它没有很好的记录,但应该不难解决.作为奖励,此 repo 还包含一个有用的脚本,可自动将 3rd 方库捆绑到应用程序包中.

FINAL EDIT: I now do this kind of stuff using a python script which I have just made public on github. It's not well documented but shouldn't be difficult to work out. As a bonus this repo also contains a useful script to automatically bundle 3rd party library into an app bundle.

推荐答案

如果我正确理解你的问题,你想修改Project-Info.plist文件,这是标准的一部分Xcode 的项目模板?

If I understand your question correctly, you want to modify the Project-Info.plist file, which is a part of the standard project template of Xcode?

我问这个的原因是 Project-Info.plist 通常是在版本控制之下的,修改它意味着它会被标记为,嗯,修改过.

The reason I ask this is that Project-Info.plist normally is under version control, and modifying it means that it will be marked as, well, modified.

如果这对您没问题,那么以下代码段将更新内部版本号并将文件标记为在此过程中已修改,其中 get_build_number 是一些脚本(即本例中的占位符)获取您要使用的(可能增加的)内部版本号:

If that is fine with you, then the following snippet will update the build number and mark the file as modified in the process, where get_build_number is some script (i.e., a placeholder in this example) to get the (possibly incremented) build number that you want to use:

#!/bin/sh

# get_build_number is a placeholder for your script to get the latest build number
build_number = `get_build_number`

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${build_number}" ProjDir/Project-Info.plist

PlistBuddy 允许您在 plist 文件中设置任何键,而不仅仅是版本号.您可以创建所需的所有 plist 文件,并在需要时将它们包含在资源中.然后可以从包中读取它们.

PlistBuddy allows you to set any key in a plist file, not just the version number. You can create all the plist files you want, and include them in the resources if needed. They can then be read in from the bundle.

至于需要在about面板等地方显示版本,还可以考虑设置CFBundleGetInfoStringCFBundleShortVersionString.

As to your need to show the version in the about pane and other places, you can also look into setting CFBundleGetInfoString and CFBundleShortVersionString.

这篇关于增加内部版本号的更好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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