Mac hosting guide

Archive and Export IPA Files in a CI Pipeline

Run xcodebuild archive to write the .xcarchive, then xcodebuild -exportArchive with an ExportOptions.plist to write the signed IPA. The script below templates that plist from CI variables and fails on any error.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Producing a distributable .ipa in CI takes two xcodebuild commands: xcodebuild archive writes the .xcarchive, then xcodebuild -exportArchive with an ExportOptions.plist writes the signed IPA. The friction is in that plist and in how secrets reach the build machine. This guide gives you a drop-in script, explains the fields that matter, and wires it into GitHub Actions, Buildkite and GitLab CI.

How do the two commands work together?

xcodebuild archive compiles the app for the selected scheme and writes a .xcarchive bundle containing the binary, dSYMs and signing metadata. xcodebuild -exportArchive reads that archive plus an ExportOptions.plist, applies the requested distribution method, re-signs where needed, and writes a .ipa to an export directory. Apple's Technical Note TN2339 gives the export form as xcodebuild -exportArchive -archivePath <xcarchivepath> -exportPath <destinationpath> -exportOptionsPlist <path>.

The commands are sequential. The archive must exist before export begins, and an export failure must never be masked as success.

# untested example — run against your own workspace and scheme
# Step 1 – build the archive
xcodebuild archive \
  -workspace MyApp.xcworkspace \
  -scheme "$SCHEME" \
  -configuration Release \
  -archivePath ./build/MyApp.xcarchive \
  CODE_SIGN_STYLE=Manual

# Step 2 – export the IPA
xcodebuild -exportArchive \
  -archivePath ./build/MyApp.xcarchive \
  -exportPath  ./build/export \
  -exportOptionsPlist ExportOptions.plist

Which ExportOptions.plist fields matter?

Your toolchain is the authority on valid keys. TN2339 says to run xcodebuild -help in Terminal to list every available key for -exportOptionsPlist. Do that on the build Mac before you lock a plist, because the list changes between Xcode versions.

Three keys drive nearly every pipeline:

KeyTypePurpose
methodStringDistribution channel. Historically accepted values include app-store, ad-hoc, development, enterprise and developer-id. Newer Xcode versions also expose names that align with the flow in Distributing your app for beta testing and releases (for example release-testing, debugging). Confirm the exact spelling for your Xcode with xcodebuild -help.
teamIDStringYour 10-character Apple developer team identifier.
provisioningProfilesDictionaryMaps each bundle ID to a provisioning profile name or UUID when signingStyle is manual.

Also useful: uploadSymbols (include dSYMs with App Store submissions), signingStyle (manual or automatic), thinning (app thinning for ad-hoc exports), and compileBitcode or uploadBitcode where still relevant. App Store bitcode submission was removed in recent Xcode releases, so xcodebuild -help is again the authoritative check.

How do I template ExportOptions.plist from CI variables?

The script below reads TEAM_ID, BUNDLE_ID, PROVISIONING_PROFILE_NAME, METHOD, SCHEME, and WORKSPACE or PROJECT from the environment, writes a temporary plist, archives, exports, and exits non-zero on any failure. Keep sensitive values in your CI secret manager and reference them by name. Import the encrypted .p12 signing certificate (it carries the private key) into the build Mac's login keychain before the run, and copy each .mobileprovision into ~/Library/MobileDevice/Provisioning Profiles/, because provisioning profiles are files on disk, not Keychain items. Do not dump the shell environment to a plaintext file or log. Unrelated secrets sit next to the variables you need, and a separate CI step runs in a separate shell that cannot see a temp filename from the previous one unless you persist it carefully.

#!/usr/bin/env bash
# export-ipa.sh — Produce a signed IPA from CI environment variables.
# Untested example. Run against your own workspace and scheme first.
#
# Required env vars:
#   TEAM_ID                   10-character Apple team identifier
#   BUNDLE_ID                 App bundle identifier (e.g. com.example.myapp)
#   PROVISIONING_PROFILE_NAME Profile name as shown in Apple Developer portal
#   METHOD                    Valid for your Xcode (see `xcodebuild -help`)
#   SCHEME                    Xcode scheme to archive (yours, not a guess)
#   WORKSPACE or PROJECT      Path to .xcworkspace or .xcodeproj
#
# Optional:
#   ARCHIVE_PATH   (default: build/App.xcarchive)
#   EXPORT_PATH    (default: build/export)

set -euo pipefail
umask 077

: "${TEAM_ID:?}" "${BUNDLE_ID:?}" "${PROVISIONING_PROFILE_NAME:?}" \
  "${METHOD:?}" "${SCHEME:?}"

ARCHIVE_PATH="${ARCHIVE_PATH:-build/App.xcarchive}"
EXPORT_PATH="${EXPORT_PATH:-build/export}"

# Create the plist with a single mktemp call so the restrictive mode sticks.
EXPORT_OPTIONS_PLIST="$(mktemp -t ExportOptions.XXXXXX)"
trap 'rm -f "$EXPORT_OPTIONS_PLIST"' EXIT

mkdir -p "$(dirname "$ARCHIVE_PATH")" "$EXPORT_PATH"

cat > "$EXPORT_OPTIONS_PLIST" <<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>${METHOD}</string>
  <key>teamID</key>
  <string>${TEAM_ID}</string>
  <key>signingStyle</key>
  <string>manual</string>
  <key>provisioningProfiles</key>
  <dict>
    <key>${BUNDLE_ID}</key>
    <string>${PROVISIONING_PROFILE_NAME}</string>
  </dict>
  <key>uploadSymbols</key>
  <true/>
</dict>
</plist>
PLIST

if [[ -n "${WORKSPACE:-}" ]]; then
  SOURCE_FLAGS=(-workspace "$WORKSPACE")
elif [[ -n "${PROJECT:-}" ]]; then
  SOURCE_FLAGS=(-project "$PROJECT")
else
  echo "ERROR: set WORKSPACE or PROJECT" >&2; exit 1
fi

echo "==> Archiving scheme: $SCHEME"
xcodebuild archive \
  "${SOURCE_FLAGS[@]}" \
  -scheme        "$SCHEME" \
  -configuration Release \
  -archivePath   "$ARCHIVE_PATH" \
  CODE_SIGN_STYLE=Manual

echo "==> Exporting IPA to $EXPORT_PATH"
xcodebuild -exportArchive \
  -archivePath        "$ARCHIVE_PATH" \
  -exportPath         "$EXPORT_PATH" \
  -exportOptionsPlist "$EXPORT_OPTIONS_PLIST"

IPA_PATH="$(find "$EXPORT_PATH" -maxdepth 2 -name '*.ipa' | head -1)"
[[ -n "$IPA_PATH" ]] || { echo "ERROR: no IPA found in $EXPORT_PATH" >&2; exit 1; }

echo "IPA_PATH=${IPA_PATH}"

This is an untested example, so run it against your own workspace and scheme before you trust it. set -euo pipefail plus the : parameter checks stop the script on a missing variable or a non-zero xcodebuild exit, so a failed build is never counted as a successful artifact. umask 077 runs before the plist is written so the temp file is readable only by the running user. The trap removes the plist on normal exit and on error, but a hard machine failure can still leave it behind. Do not assume if: always() cleans up after a forced termination.

What do the common failures mean?

"No signing certificate found": the .p12 was not imported into the build Mac's login keychain, or it has expired. Verify with security find-identity -v -p codesigning.

"Provisioning profile does not match bundle identifier": the key in provisioningProfiles must be the app's bundle ID exactly, and the value must match the profile name shown in the Apple Developer portal, not the filename on disk.

"Missing required entitlement": the embedded profile does not include a capability the app declares. Regenerate the profile in the portal, copy the updated .mobileprovision into ~/Library/MobileDevice/Provisioning Profiles/, and rerun.

Non-zero exit with no visible reason: add -verbose to either xcodebuild command and search the log for lines starting with error:. Signing failures surface there before the final ** ARCHIVE FAILED ** summary.

Where does the IPA land?

It lands inside EXPORT_PATH with a filename matching the scheme's product name. The script prints IPA_PATH=<path> so later CI steps can use it. In GitHub Actions, append the value to $GITHUB_OUTPUT. In Buildkite, capture it with buildkite-agent meta-data set. In GitLab CI, write it to a dotenv artifact and read it in the next job.

How do I wire the script into CI?

GitHub Actions

- name: Build IPA
  env:
    WORKSPACE:                 MyApp.xcworkspace
    SCHEME:                    MyApp
    METHOD:                    app-store
    TEAM_ID:                   ${{ secrets.TEAM_ID }}
    BUNDLE_ID:                 com.example.myapp
    PROVISIONING_PROFILE_NAME: ${{ secrets.PROFILE_NAME }}
  run: bash ci/export-ipa.sh

- name: Upload IPA artifact
  uses: actions/upload-artifact@v4
  with:
    name: MyApp-ipa
    path: build/export/*.ipa
    retention-days: 7

GitLab CI

build_ipa:
  tags: [mac-arm64]
  script:
    - bash ci/export-ipa.sh
  artifacts:
    paths: [build/export/*.ipa]
    expire_in: 1 week

Buildkite

steps:
  - label: ":iphone: Build IPA"
    command: bash ci/export-ipa.sh
    env:
      WORKSPACE: MyApp.xcworkspace
      SCHEME:    MyApp
      METHOD:    ad-hoc
    artifact_paths: "build/export/*.ipa"

If your runners sit behind an egress firewall, update only the allowlists you control: your Git host, your artifact store, your secret manager and the Apple endpoints your pipeline calls. There is no published blanket App Store Connect or TestFlight IP range to paste in.

Should I keep the IPA as an artifact or upload straight to TestFlight?

Store the IPA as a CI artifact first. That gives you a downloadable build to inspect before testers see it, and keeps archive and distribute as separate failure domains. Once the build is verified, a follow-on step can upload with xcrun altool --upload-app or the App Store Connect API. If you upload automatically, treat any rejection as a build failure and show the response in the CI log instead of retrying silently.

Which Figment Mac plan fits this job?

Match the Mac to the Xcode your scheme needs. Use the Apple Silicon Mac VM ($0.40 an hour, $6 a day, $39 a month) when the scheme needs arm64 simulators or current Xcode (Xcode 26.4 or later needs Tahoe 26.2 or later, Xcode 27 needs Tahoe 26.6 or later), and the Dedicated M4 Pro 48 GB ($349 a month) for heavy archives or parallel builds. If your project pins Xcode 26.3 or earlier and you only need periodic signed IPAs, the Intel Mac VM ($0.15 an hour, $2 a day, $25 a month) runs the same two commands on macOS Sequoia. It cannot run arm64-only binaries or visionOS. Apple's porting guide notes that Xcode 27 runs on Apple silicon, and if you must produce an Intel binary from an Apple silicon host you add x86_64 to the ARCHS build setting. See Apple's porting guidance.

Figment runs the Mac; you manage Xcode, signing and the pipeline, and we do not offer managed CI. Check the macOS version shown before purchase against Apple's Xcode table. Several Macs are quoted on a call.

Related guides

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan