Incrementing iOS app version

To make your build version management easy, Nevercode exports two environment variables that you can use in your build scripts: NEVERCODE_BUILD and NEVERCODE_BUILD_NUMBER. Read more about their meaning from here.

Since the iOS build ecosystem supports running arbitrary scripts as a part of your build process, you can check the existence and the value of these environment variables in either bash or a scripting language of your choice (such as Ruby or Python).

Here is an example of updating your build version using a simple bash script.

DSYM_INFO_PLIST="${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist"
buildNumber=$NEVERCODE_BUILD_NUMBER
stringLength=${#buildNumber}

if [ $stringLength -ne 0 ]; then
    echo "Updating build number to $buildNumber"
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
    if [ -f "$DSYM_INFO_PLIST" ]; then
        /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$DSYM_INFO_PLIST"
    fi
else
    echo "Missing build number, skip updating"
fi

To use build versioning in your project, do the the following in Xcode:

  • Select: your Target in Xcode,
  • Select: Build Phases Tab,
  • Select: Add Build Phase -> Add Run Script,
  • Paste code above in to “Run Script” section,
  • Drag the “Run Script” below “Copy Bundle Resources”.

Updated 3 years ago

Incrementing iOS app version


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.