Search code examples
xcodegitbuild-processversioningrun-script

Global Xcode run scripts


In order to automatically update build dates and build numbers, I set up a run script for the build phase in my scheme:

# Auto Increment Version Script
buildPlist=${PROJECT_DIR}/${INFOPLIST_FILE}
CFBuildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBuildNumber" $buildPlist)
CFBuildNumber=$(($CFBuildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBuildNumber $CFBuildNumber" $buildPlist
# "Mon" is a hack, but day is needed, and in English
CFBuildDate=$(date "+Mon %b %d %H:%M:%S %Z %Y")
/usr/libexec/PlistBuddy -c "Set :CFBuildDate $CFBuildDate" $buildPlist

While this works, the downside is that the schemes are bound to the user-specific settings, i.e. they are are excluded from version control and may easily get lost.

What's the proper way to tackle this problem and make those scripts available to all developers?


Solution

  • There is a "Shared" checkbox in the scheme settings. By checking it, your schemes will be saved in the project global settings and not in your user specific settings folder. This also makes it so that the scheme will be included in an git commit, etc (assuming that the project settings folders arent ignore in gitignore). You can keep ".xcuserdata" in .gitignore, and the scheme will still be included in your repo.
    screenshot:

    enter image description here