如何在 Xcode 5 中自动增加内部版本号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21114376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to auto increment the build number in Xcode 5
提问by seinfeld
I was wondering if Xcode 5 is providing a setting to automatically count up the Build number found under General in the Identity section of the project navigator.
我想知道 Xcode 5 是否提供了一个设置来自动计算在项目导航器的 Identity 部分的 General 下找到的 Build number 。
But afaik you still have to do it with scripting, using PlistBuddy.
但是你仍然必须使用 PlistBuddy 编写脚本来完成它。
One simple solution is to increase the build number in Xcode 5 is posted below:
一种简单的解决方案是增加 Xcode 5 中的内部版本号,如下所示:
回答by seinfeld
Go to Editor -> Add Build Phase -> Add Run Script Build Phase
转到编辑器 -> 添加构建阶段 -> 添加运行脚本构建阶段
Go to Build Phases in the project navigator and edit Run Sript. Change Shell to /bin/bash and paste the following script:
转到项目导航器中的 Build Phases 并编辑 Run Sript。将 Shell 更改为 /bin/bash 并粘贴以下脚本:
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
Don't forget to change the Build number found under General in the Identity section from 1.0 to 1
不要忘记将 Identity 部分 General 下的 Build number 从 1.0 更改为 1
Have fun! :)
玩得开心!:)