Skip to content

Instantly share code, notes, and snippets.

@fabb
Created November 1, 2014 12:39
Show Gist options
  • Save fabb/7c0d24cb7c9c0eb87f9d to your computer and use it in GitHub Desktop.
Save fabb/7c0d24cb7c9c0eb87f9d to your computer and use it in GitHub Desktop.
Script to archive an ipa from commandline - depends on xctool
#!/bin/bash
set -x
cd ${0%/*}/..
# codesigning and choosing of provisioning profile is configured via project settings and is dependent of build config
: ${BUILD_NUMBER:?"Need to set BUILD_NUMBER"}
WORKSPACE=<yourworkspace>.xcworkspace
SCHEME=<yourscheme>
ARCHIVEPATH=`pwd`/archive
IPA_NAME=<youroutputfilename>
PROJECT_BUILDDIR=${ARCHIVEPATH}/${IPA_NAME}.xcarchive/Products/Applications
DSYM_INPUT_PATH=${ARCHIVEPATH}/${IPA_NAME}.xcarchive/dSYMs
DSYM_ZIP_OUTPUT_PATH=${ARCHIVEPATH}/${IPA_NAME}.dSYM.zip
xctool -workspace ${WORKSPACE} -scheme ${SCHEME} archive -archivePath "${ARCHIVEPATH}/${IPA_NAME}"
xcrun -sdk iphoneos PackageApplication -v "${PROJECT_BUILDDIR}"/*.app -o "${ARCHIVEPATH}/${IPA_NAME}.ipa"
# resigning not necessary, as building already uses correct codesigning and choosing of provisioning profile
# zipping dSYM for testflight upload
( cd ${DSYM_INPUT_PATH} ; zip -r -X ${DSYM_ZIP_OUTPUT_PATH} *.dSYM )
@fabb
Copy link
Author

fabb commented Nov 1, 2014

The script depends on xctool.

The script assumes the following project file structure:

project_dir/
    <yourworkspace>.xcworkspace
    scripts/
        archive_ipa.sh
    archive/
        <archive output files>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment