Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Last active November 2, 2022 14:05
Show Gist options
  • Save gauravkeshre/10dfd827c52ba53e83b14d292792fb49 to your computer and use it in GitHub Desktop.
Save gauravkeshre/10dfd827c52ba53e83b14d292792fb49 to your computer and use it in GitHub Desktop.
AddBranchDescriptionToArchiveDescription

Objective

Get some information about the Branch and Commit in the archive comment in xcode organizer

Setup

  1. Launch Xcode
  2. Open Schema management ( + ^ + i )
  3. Select "Atchive" tab
  4. Under Archive tab, select "Post-actions"
  5. + > "New Run Script Action"
  6. Paste the below script 6.1 Altenatively, you can store the script in an sh file and paste the url in the script section
  7. Under "Provice Build Settings from" <Select your project/workspace>
  8. Under Archive tab, select "Archive"
  9. Uncheck "Releave Archive in Organizer"

Demo

archive_info_image

#!/bin/sh
ARCHIVE_PATH=$(dirname "$ARCHIVE_PRODUCTS_PATH")
ARCHIVE_PLIST=${ARCHIVE_PATH}/Info.plist
CURRENT=$(pwd)
# Switch to project directory from archive dir
cd $PROJECT_FILE_PATH
# capture current branch name and commit message
BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
MESSAGE=$(git log -1 --pretty=format:"\"%s\" on %ai" $*)
# cd back into archive dir
cd $CURRENT
# Write plist
/usr/libexec/PlistBuddy -c "Add :Comment string \"Branch - ${BRANCH} \n ${MESSAGE}\"" "${ARCHIVE_PLIST}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment