Skip to content

Instantly share code, notes, and snippets.

@spenserpothier
Last active September 10, 2024 06:26
Show Gist options
  • Save spenserpothier/8fd164f2a6b15d3b1cd023ec36a8f0ef to your computer and use it in GitHub Desktop.
Save spenserpothier/8fd164f2a6b15d3b1cd023ec36a8f0ef to your computer and use it in GitHub Desktop.
Use xcodebuild for iOS builds
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>ad-hoc</string>
<key>teamID</key>
<string>10_DIGIT_DEVELOPER_ID</string>
<key>provisioningProfiles</key>
<dict>
<key>MY_APP_BUNDLE_ID</key>
<string>MY_PROFILE_NAME_AS_SHOWN_BY_XCODE or UUID_FOUND_IN_MOBILEPROVISION_FILE</string>
</dict>
<key>signingCertificate</key>
<string>iOS Distribution</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>YOUR_TEN_CHARACTER_TEAM_ID</string>
</dict>
</plist>
# if code signing fails, probably due to keychain being locked. Unlock with the following:
$ security unlock-keychain login.keychain
# Clean build folder
$ xcodebuild \
-workspace ${WORKSPACE_PATH} \
-scheme ${SCHEME_NAME} \
-destination generic/platform=iOS \
clean
# Create generic iOS Build
$ xcodebuild \
-workspace ${WORKSPACE_PATH} \
-scheme ${SCHEME_NAME} \
-destination generic/platform=iOS \
build
# Create Archive for ad-hoc distribution
$ xcodebuild \
-workspace ${WORKSPACE_PATH} \
-scheme ${SCHEME_NAME} clean archive \
-configuration release \
-sdk iphoneos \
-archivePath ${ARCHIVE_NAME}.xcarchive
# Export Archive for adhoc distribution
$ xcodebuild \
-exportArchive \
-archivePath ${ARCHIVE_NAME}.xcarchive \
-exportOptionsPlist exportOptions-AdHoc-Distribution.plist \
-exportPath ${ARCHIVE_NAME}
# IPA file found in ${ARCHIVE_NAME}/
# Create archive for App Store distribution
$ xcodebuild -workspace ${WORKSPACE_PATH} \
-scheme ${SCHEME_NAME} \
-sdk iphoneos \
-configuration AppStoreDistribution archive \
-archivePath ${ARCHIVE_NAME}.xcarchive
# Export archive for App Store distribution
$ xcodebuild -exportArchive \
-archivePath ${ARCHIVE_NAME}.xcarchive \
-exportOptionsPlist exportOptions-App-Store-Distribtuion.plist \
-exportPath ${ARCHIVE_NAME}
# Upload to iTunes Connect
$ xcrun altool --upload-app -f "path/to/app.ipa" -u $USERNAME -p $PASSWORD
@spenserpothier
Copy link
Author

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