AppForShareGet a token

Upload from CI

Xcode Cloud

Xcode Cloud runs ci_scripts/ci_post_xcodebuild.sh after each build. When the archive action exports an ad hoc build, CI_AD_HOC_SIGNED_APP_PATH points to the folder with the .ipa, and the script uploads it.

1. Add your token

Create an API token under Dashboard, Settings, API tokens (Pro and Team). In the workflow, Environment, add APPFORSHARE_TOKEN and mark it Secret. The CLI reads it from the APPFORSHARE_TOKEN environment variable.

2. ci_scripts/ci_post_xcodebuild.sh

Make it executable (chmod +x) and commit it. Node is not on the image by default, so the script installs it with Homebrew first.

#!/bin/sh
set -e
# Only after an archive that produced an ad hoc export.
[ -n "$CI_AD_HOC_SIGNED_APP_PATH" ] || exit 0
IPA=$(find "$CI_AD_HOC_SIGNED_APP_PATH" -name "*.ipa" | head -1)
[ -n "$IPA" ] || exit 0
brew install node
cd "$CI_PRIMARY_REPOSITORY_PATH"
npx --yes appforshare upload "$IPA" --notes "$(git log -1 --pretty=%B)" --channel beta

Good to know

  • Use an Archive action. The script uploads only when Xcode Cloud made an ad hoc signed export, which needs the testers' iPhones in your Apple account. AppForShare can collect UDIDs and register them there.
  • TestFlight builds from Xcode Cloud do not need this script; AppForShare can keep your TestFlight groups and testers in step instead.
  • Add --channel beta to keep one stable link for testers, and --fail-on blocked to stop the pipeline when the store readiness check finds a blocker (exit code 2; the build stays uploaded).
  • The command prints the install link. Add --json for url, slug, version and channel as JSON. All options are on Upload from CI.

Questions

Does installing Node slow the build?
It adds a short Homebrew step after the build. The upload itself resumes if the connection drops.
Why does the script exit without uploading?
CI_AD_HOC_SIGNED_APP_PATH is empty when the action did not export an ad hoc build, for example on test or analyze actions. The script skips those on purpose.

Other CI systems

GitHub Actions and FastlaneCircleCIGitLab CIBitbucket PipelinesJenkinsAzure PipelinesCodemagicBitriseExpo EAS