Is there a way of automatically writing custom values to the bundle's .plist during a build phase?

后端 未结 1 1384
栀梦
栀梦 2020-12-21 02:19

I\'m setting up a CI system using Jenkins and am using agvtool to bump and set marketing & technical versions at build time.

In addition to setting the versionin

相关标签:
1条回答
  • 2020-12-21 02:46

    You can edit the Info.plist at build time by taking advantage of the "Pre-actions" options to run a script.

    enter image description here

    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.

    0 讨论(0)
提交回复
热议问题