Skip to content

Instantly share code, notes, and snippets.

@boyvanamstel
Last active July 17, 2023 04:53
Show Gist options
  • Save boyvanamstel/f38df803eb6e0cb8cdf2 to your computer and use it in GitHub Desktop.
Save boyvanamstel/f38df803eb6e0cb8cdf2 to your computer and use it in GitHub Desktop.
Xcode archive post-action to copy zip, dSYM and DMG (using DropDMG) to desktop
VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${SOURCE_ROOT}/${INFOPLIST_FILE}")
BUILD=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${SOURCE_ROOT}/${INFOPLIST_FILE}")
# The build number gets automatically increased by a build phase
BUILD=$((BUILD - 1))
DATE=$(/bin/date +%Y%m%d%H%M%S)
OUTPUT_DIR="${HOME}/Desktop/${TARGET_NAME}_v${VERSION}b${BUILD}_${DATE}"
mkdir "$OUTPUT_DIR"
# Zip and copy .dSYM
cd "${ARCHIVE_DSYMS_PATH}/"
/usr/bin/zip -r "$OUTPUT_DIR/${TARGET_NAME}.dSYM.zip" "${TARGET_NAME}.app.dSYM"
# Create dmg
# Store your DropDMG layout in ${Source_ROOT}/DropDMG
/usr/local/bin/dropdmg "${ARCHIVE_PRODUCTS_PATH}/Applications/${TARGET_NAME}.app" --layout-folder "${SOURCE_ROOT}/DropDMG/Layout" --destination "$OUTPUT_DIR"
# Zip and copy .app
cd "${ARCHIVE_PRODUCTS_PATH}/Applications/"
/usr/bin/zip -r -y "$OUTPUT_DIR/${TARGET_NAME}.app.zip" "${TARGET_NAME}.app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment