我希望应用编译的时候,可以把git的版本号自动添加到identifier和bundle name上,这样在开发阶段就可以非常方便的查看到底是哪个版本在进行测试。
我现在的做法是每次手动的把这个版本号加上去,非常痛苦。。有时候忘了加,版本就乱了
迷茫2017-04-17 11:19:51
1, open and click Project
2. Select target and enter Build Phases
3. Click Editor on the toolbar, Add Build Phases, and select Add Run Script Build Phases.
4. The target’s build Phases will include a Run Script
Add the following code
git status version=$(git describe --tags) echo version: $version info_plist=$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Info.plist /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $version" $info_plist
Use the following code to test in the project
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; NSLog(@"%@",version);
Reference link:
http://feinstruktur.com/blog/2010/12/...
迷茫2017-04-17 11:19:51
git_version=`git rev-parse --short HEAD` app_version=`git describe --tags` /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $app_version" $PRODUCT_SETTINGS_PATH /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $git_version" $PRODUCT_SETTINGS_PATH