让iOS App编译的时候自动带git版本号
大家讲道理
大家讲道理 2017-04-17 11:17:51
0
2
344

我希望应用编译的时候,可以把git的版本号自动添加到identifier和bundle name上,这样在开发阶段就可以非常方便的查看到底是哪个版本在进行测试。
我现在的做法是每次手动的把这个版本号加上去,非常痛苦。。有时候忘了加,版本就乱了

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
迷茫

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/...

迷茫
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template