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`
Hi based on other answers I did something like that:
- click on project icon the select "Edit Scheme..."
- select "Archive/Post-actions"
- press "+" "New Run script action"
- Change "Provide build settings from" to desired project
- Select shell
- 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).