Skip to content

Instantly share code, notes, and snippets.

@madhikarma
Last active June 8, 2020 08:33
Show Gist options
  • Save madhikarma/a744543ba8568271bad8f627df2b4cc7 to your computer and use it in GitHub Desktop.
Save madhikarma/a744543ba8568271bad8f627df2b4cc7 to your computer and use it in GitHub Desktop.
xcodebuild script
#!/bin/sh
set -eo pipefail
IFS=$'\n\t'
# Constants
NOW=$(date +%s)
BUILD_FILE_NAME="MyApp-${NOW}"
SCHEME="MyApp"
WORKSPACE="MyApp"
PROJECT="MyApp"
CONFIGURATION="AdHoc"
PROFILE_NAME="MyApp AdHoc"
CODE_SIGN_IDENTITY_NAME="iPhone Distribution: company name here"
# Build (project)
xcodebuild -archivePath "${BUILD_FILE_NAME}.xcarchive" -project "${PROJECT}.xcodeproj" -scheme "${SCHEME}" -configuration "${CONFIGURATION}" archive clean
# Build (workspace)
#xcodebuild -archivePath "${BUILD_FILE_NAME}.xcarchive" -workspace "${WORKSPACE}.xcworkspace" -scheme "${SCHEME}" -configuration "${CONFIGURATION}" archive clean
# Export archive (code sign using export options plist to specify bitcode etc)
# Newer but not working in Xcode 8 if you use rvm to set non system Ruby (Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found.")
#xcodebuild -exportArchive -exportOptionsPlist "exportOptions-adhoc.plist" -archivePath "${BUILD_FILE_NAME}.xcarchive" -exportPath "${BUILD_FILE_NAME}.ipa"
# Export archive (code sign using profile and code sign identity)
# Legacy but still working (Warning: xcodebuild: WARNING: -exportArchive without -exportOptionsPlist is deprecated)
xcodebuild -exportArchive -archivePath "${BUILD_FILE_NAME}.xcarchive" -exportPath "${BUILD_FILE_NAME}.ipa" -exportFormat ipa -exportProvisioningProfile "${PROFILE_NAME}" CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY_NAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment