# Verify an iOS IPA Checksum Before Deployment

Canonical: https://figment.so/blog/mac-ci-artifact-integrity-verify

Run shasum -a 256 on the exported IPA, store the digest and the commit SHA as separate files, and check both before you promote the build. This catches accidents, not a determined attacker.

Record a SHA-256 digest of the IPA right after export, store the commit SHA in a separate file, and verify both before you promote the build. The digest tells you whether the file changed. The commit record helps catch an artifact built from the wrong revision. To create the IPA first, follow the [Xcode archive and export guide](/blog/mac-ipa-archive-export-ci).

The Figment team tested the four shell snippets on macOS with a synthetic artifact. The intact file passed. Changed bytes and a wrong commit each failed. This test did not use a signed IPA, a hosted runner, or an attestation.

## What does a checksum prove, and what does it not?

A SHA-256 digest is a fixed-length fingerprint of a file's exact bytes. If a single byte changes in transit, decompression, or accidental overwrite, the digest will not match. A match is strong evidence that the file has the bytes you recorded.

A checksum does not sign the file, does not prove who produced it, and does not show that the build inputs were trustworthy. Those are provenance claims. Use the digest to catch ordinary transfer corruption and wrong-commit mistakes. If an adversary can replace both the IPA and the digest file, the check gives no protection.

## How do I record the digest after export?

Run `shasum -a 256` on the exported IPA as the very next step after export, and after the last signing or packaging step. Re-signing or repackaging afterward changes the bytes. Moving the file to a new path does not.

The snippet uses a subshell `cd` so the digest file records a bare filename, `MyApp.ipa`, rather than a build-directory path. Verification then works from any directory the artifact is later downloaded to.

```bash
# Record a SHA-256 digest of the exported IPA
ARTIFACT_DIR="build/Export"

(cd "$ARTIFACT_DIR" && shasum -a 256 MyApp.ipa > MyApp.ipa.sha256)
cat "$ARTIFACT_DIR/MyApp.ipa.sha256"
# example output: <64-character digest> MyApp.ipa
```

Record the commit SHA in a **separate** sidecar file so the digest file contains only checksum lines. Other content in the `.sha256` file makes `shasum --strict -c` fail at verification.

```bash
# Record the commit SHA in a separate sidecar
git rev-parse HEAD > "$ARTIFACT_DIR/commit.txt"
```

Upload the `.ipa`, `.sha256`, and `commit.txt` as CI artifacts. Uploading them together does not stop someone with write access from replacing all three, so use this check to catch accidents and use provenance verification for a stronger trust claim.

## How do I verify the digest before deployment?

At any later gate (a separate job, a release pipeline, or a manual promotion), download the artifact directory and run `shasum` in check mode from inside it. The `--strict` flag rejects any line that does not match the digest-file format. It is safe here because the digest file holds only checksum lines.

```bash
# Verify IPA digest from the artifact directory
ARTIFACT_DIR="artifacts"   # wherever the CI download step placed the files

(cd "$ARTIFACT_DIR" && shasum -a 256 --strict -c MyApp.ipa.sha256)
# prints: MyApp.ipa: OK
# exits non-zero if the file has changed
```

Fail the pipeline on any non-zero exit. If the check fails because the artifact was legitimately re-signed or repackaged after the digest was recorded, regenerate the digest from the new file and document the re-signing step.

## How do I check that the IPA came from the right commit?

Compare `commit.txt` with `EXPECTED_SHA`, a value you supply from **trusted release metadata**, such as a release tag annotation or a promotion parameter set by a human reviewer. A matching digest confirms byte identity but not which commit produced the file, and `commit.txt` records that at build time.

Do not derive `EXPECTED_SHA` by running `git rev-parse HEAD` in the verification job, because that returns whatever HEAD is in that job's workspace, not the commit the artifact was built from. Do not read it from the artifact itself either, because that is circular.

```bash
# Supply EXPECTED_SHA from your trusted release metadata,
# e.g. a release tag annotation or a pipeline promotion parameter
EXPECTED_SHA="<commit SHA from trusted release metadata>"
RECORDED_SHA="$(cat "$ARTIFACT_DIR/commit.txt")"

if [ "$EXPECTED_SHA" != "$RECORDED_SHA" ]; then
  echo "Commit mismatch: expected $EXPECTED_SHA, got $RECORDED_SHA" >&2
  exit 1
fi
```

This catches artifact mix-ups, for example a stale cached artifact promoted into a release branch, without signing infrastructure. It is a convention, not a cryptographic proof. If an adversary can replace both `commit.txt` and the IPA, neither check protects you.

## Should I use GitHub artifact attestation instead?

Use it in addition if your plan supports it. GitHub Actions provides `actions/attest`, which **generates** a signed provenance statement linking an artifact to its workflow run and repository. The `gh attestation verify` CLI **verifies** the digest and identity against that attestation; it does not generate one. The signature from the workflow's identity gives a stronger provenance claim than a plain digest. The [GitHub documentation](https://docs.github.com/en/actions/how-tos/secure-your-work/use-artifact-attestations/use-artifact-attestations) covers setup and options.

Check these limits before you rely on it:

- Current GitHub plans support attestations for public repositories. Private or internal repositories require GitHub Enterprise Cloud. Check the current terms for your repository.
- Verify against the expected owner and repository. Copying the file does not create a new attestation.

The digest catches byte-level changes quickly with no external dependency. Attestation adds verifiable provenance. Neither replaces review of your pipeline's secret handling and branch protection rules.

## Which Figment Mac plan fits this work?

Any plan can run these checks, because `shasum` and `git` need almost no compute. Choose the plan for the build that produces the IPA: the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) for current Xcode, or the [Intel Mac VM](/mac-hosting#intel-vm) only if Xcode 26.3 or earlier on macOS Sequoia is enough. You run your own CI runner on the Mac. For notes on the editorial method and the test constraints behind this guide, see [Figment editorial method](/mac-hosting/editorial-method).
