Xcode : Generating an automatic comment upon Archive Xcode : Generating an automatic comment upon Archive xcode xcode

Xcode : Generating an automatic comment upon Archive


We use the following command to add a comment to the archive directly after the build (xcodebuild):

/usr/libexec/PlistBuddy -c "Add :Comment string \"your comment goes here\"" "$ARCHIVE_DIR/Info.plist"

with $ARCHIVE_DIR being the directory to the archive in question, e. g.:

ARCHIVE_DIR=`ls -dt1 $HOME/Library/Developer/Xcode/Archives/*/*.xcarchive |head -n1`


I tried Norman's idea but couldn't get the syntax to work. In the end I used:

ARCHIVE_DIR=$(ls -dt1 $HOME/Library/Developer/Xcode/Archives/*/*.xcarchive/Info.plist |head -n1)/usr/libexec/PlistBuddy -c "Add :Comment string \"your comment goes here\"" "$ARCHIVE_DIR"


Hi based on other answers I did something like that:

  1. click on project icon the select "Edit Scheme..."
  2. select "Archive/Post-actions"
  3. press "+" "New Run script action"
  4. Change "Provide build settings from" to desired project
  5. Select shell
  6. paste this script (assuming that git is used):
cd "$PROJECT_FILE_PATH"BRANCH=$(basename `git describe --all`)COMMIT_HASH=$(git rev-parse HEAD | awk '{print substr($0,0,7)}')ARCHIVE_PATH=$(dirname "$ARCHIVE_PRODUCTS_PATH")ARCHIVE_NAME=${ARCHIVE_PATH}/Info.plistDEST_DIR="<desired destination path>"/usr/libexec/PlistBuddy -c "Add :Comment string \"${BRANCH}_${COMMIT_HASH}\""  "$ARCHIVE_NAME"if [ -d "$DEST_DIR" ]; then    PACKAGE_NAME=$DEST_DIR/${BRANCH}_${COMMIT_HASH}_${PRODUCT_NAME}    xcodebuild -sdk $SDKROOT -archivePath "$ARCHIVE_PATH" -exportPath "$PACKAGE_NAME" -exportFormat ipa -exportArchive -exportProvisioningProfile "your provisioning profile name"fi

Advantage on other solution is that archive is localized based on XCode variable not based on search (unnecessary overhead).