有没有一种方法可以在构建阶段自动将自定义值写入bundle的.plist? [英] Is there a way of automatically writing custom values to the bundle's .plist during a build phase?
问题描述
我正在使用Jenkins设置CI系统,并使用agvtool进行颠覆和设置营销&构建时的技术版本。
I'm setting up a CI system using Jenkins and am using agvtool to bump and set marketing & technical versions at build time.
除了在构建时设置版本控制外,在.plist中设置几个自定义值非常有用。
In addition to setting the versioning at build time it would be very useful to set a couple of of custom values in the .plist.
这可能吗?
推荐答案
您可以在以下位置编辑Info.plist:通过利用预操作选项来运行脚本来构建时间。
You can edit the Info.plist at build time by taking advantage of the "Pre-actions" options to run a script.
这是一个示例脚本,用于递增Plist中的Key,称为UserDefinedVersionNumber
Here's an example script that increments a Key in the Plist called UserDefinedVersionNumber
#!/bin/sh
#Grabs info from plist
plist=$SRCROOT"/"$INFOPLIST_FILE
currentBuild=`/usr/libexec/PlistBuddy -c "Print :UserDefinedVersionNumber" "$plist"`
#And changes it before writing out the plist again
if [ -z "$currentBuild" ]
then
currentBuild=1
/usr/libexec/PlistBuddy -c "Add :UserDefinedVersionNumber string $currentBuild" "$plist"
else
currentBuild=$(($currentBuild + 1));
/usr/libexec/PlistBuddy -c "Set :UserDefinedVersionNumber $currentBuild" "$plist"
fi
您应该可以直接在该小方框中输入脚本,但我发现编辑和维护它会变得很麻烦,尤其是对于共享脚本。
You should be able to type the script directly into that little box, but I find that editing and maintaining it can become troublesome, especially for shared scripts.
这篇关于有没有一种方法可以在构建阶段自动将自定义值写入bundle的.plist?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!