Reputation: 468
Context : My project contains two backend servers, one for development and one for production. Each time I make a build for QA, I'll need to put which server the build is on on TestFlight (this is ok). But on my archive list on Xcode, I easily get more than 100 archives where I have to put manually if it was prod or dev server.
The main issue here is when the QA needs to rollback to a specific version on a specific server.
Question : Is there an automatic way to put a comment on the archive upon building ? I would like to put something like :
[Build Number] - [Dev|Live] Server
Thanks
Upvotes: 8
Views: 844
Reputation: 387
Found this old post after googling, and was very annoyed by the organizer refresh problem, and just had a very ugly idea. In fact, the organizer is automatically refreshed on FS updates.
so I've just tried to move archive after updating its plist, then moving it back to its initial location. Something like this :
ARCHIVE_PATH=$(dirname "$ARCHIVE_PRODUCTS_PATH")
ARCHIVE_PLIST=${ARCHIVE_PATH}/Info.plist
/usr/libexec/PlistBuddy -c "Add :Comment string \"your comment goes here\"" "$ARCHIVE_PLIST"
mv "$ARCHIVE_PATH" "$ARCHIVE_PATH"_TMP
sleep 1
mv "$ARCHIVE_PATH"_TMP "$ARCHIVE_PATH"
Sleep is necessary to let OS X refresh folder content. You will see archive disappears then appears back again.
Hope it helps.
Upvotes: 1
Reputation: 38092
Hi based on other answers I did something like that:
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.plist
DEST_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).
Upvotes: 1
Reputation: 362
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"
Upvotes: 1
Reputation:
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`
Upvotes: 1