# Diagnose App Entitlement Errors on a Remote Mac

Canonical: https://figment.so/blog/mac-entitlements-debug-xcode

Extract entitlements from the signed binary with codesign and from the provisioning profile with security cms, then diff the key sets to find the mismatch. Every tool is stock macOS, so Figment's Intel Mac VM is enough.

**Extract the entitlements from the signed binary, extract them from the provisioning profile, and compare the two.** An app that installs in debug and silently fails in distribution almost always has an entitlement mismatch: the signed binary claims a capability the provisioning profile never granted, or the profile grants something the App ID was never enabled for. Apple's [Technical Note TN2415](https://developer.apple.com/library/archive/technotes/tn2415/_index.html) documents the resulting errors, including `error: 0xe8008016` for "entitlement not supported by your current provisioning profile" and the matching App Store submission error that names the disallowed key. All three steps run on a remote Mac in a couple of minutes.

## Why do entitlement mismatches happen?

When Xcode archives your app, it reads your `.entitlements` file and embeds those key-value pairs in the signed binary. Apple's guide on [adding capabilities to your app](https://developer.apple.com/documentation/xcode/adding-capabilities-to-your-app) describes how the Signing & Capabilities pane edits the entitlements plist, adjusts frameworks, and updates signing assets when you add a capability. At install time, and again at App Store review, the system checks that each embedded entitlement key appears in the provisioning profile's `Entitlements` dictionary. A key present in the binary but absent from the profile makes the signature invalid for that use, which leads to a failed launch, a TestFlight rejection, or an ITMS-level rejection on submission.

Three common sources of drift:

1. **A capability added in Xcode's Signing & Capabilities pane while the App ID was never updated** in the developer portal. Xcode writes the key into the `.entitlements` file, but the portal never generated a profile that includes it.
2. **A profile regenerated without re-downloading.** You enabled Push Notifications on the App ID, but Xcode still references the old cached profile.
3. **Extension targets.** A Notification Service Extension needs its own `aps-environment` entitlement in its own provisioning profile. Using the host app's profile for the extension is a frequent source of ITMS-90078.

## How do I extract entitlements from the built app?

After archiving, find the `.app` bundle inside the `.xcarchive`, or unzip the `.ipa` to get `Payload/YourApp.app`. Then run:

```bash
codesign -d --entitlements :- Payload/YourApp.app
```

The `:-` argument writes the plist to stdout. Redirect it to a file for comparison:

```bash
codesign -d --entitlements :- Payload/YourApp.app > binary_entitlements.plist
```

The output looks like this:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
    <key>aps-environment</key>
    <string>production</string>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
    </array>
</dict>
</plist>
```

This is what the binary actually contains. It can differ from your `.entitlements` source file if the build system rewrote keys during signing.

## How do I extract the allowed entitlements from the provisioning profile?

The profile is a CMS-signed envelope, so decode it first:

```bash
security cms -D -i path/to/YourApp_Distribution.mobileprovision > profile_decoded.plist
```

Then pull just the `Entitlements` dictionary:

```bash
/usr/libexec/PlistBuddy -x -c 'Print :Entitlements' profile_decoded.plist > profile_entitlements.plist
```

That gives the exact keys the profile permits. Any key present in `binary_entitlements.plist` but absent here will cause a signing failure.

## Can one script run the whole diff?

Yes. This example extracts and compares in one pass. It takes an `.ipa` and a `.mobileprovision` as arguments. Treat it as an untested example: run it against your own build, read stderr, and confirm the result before you ship.

```bash
#!/usr/bin/env bash
# Usage: ./diff_entitlements.sh MyApp.ipa MyApp_Distribution.mobileprovision
# Requires: codesign, security, PlistBuddy, plutil, python3 (all stock on macOS).
set -euo pipefail

if [ "$#" -ne 2 ]; then
  echo "Usage: $0 path/to/MyApp.ipa path/to/profile.mobileprovision" >&2
  exit 2
fi

IPA="$1"
PROFILE="$2"
[ -f "$IPA" ]     || { echo "IPA not found: $IPA" >&2; exit 2; }
[ -f "$PROFILE" ] || { echo "Profile not found: $PROFILE" >&2; exit 2; }

umask 077
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT

unzip -q "$IPA" -d "$WORK/ipa"
APP="$(find "$WORK/ipa/Payload" -maxdepth 1 -name '*.app' | head -1)"
[ -n "$APP" ] || { echo "No .app found in Payload/" >&2; exit 1; }

codesign -d --entitlements :- "$APP" > "$WORK/binary.plist"
security cms -D -i "$PROFILE" > "$WORK/profile_full.plist"
/usr/libexec/PlistBuddy -x -c 'Print :Entitlements' "$WORK/profile_full.plist" \
  > "$WORK/profile.plist"

plutil -convert json -o "$WORK/binary.json"  "$WORK/binary.plist"
plutil -convert json -o "$WORK/profile.json" "$WORK/profile.plist"

python3 - "$WORK/binary.json" "$WORK/profile.json" <<'PY'
import json, sys
with open(sys.argv[1]) as f: bin_keys  = set(json.load(f).keys())
with open(sys.argv[2]) as f: prof_keys = set(json.load(f).keys())
missing = sorted(bin_keys - prof_keys)
extra   = sorted(prof_keys - bin_keys)
print("=== Keys in binary NOT in profile (likely cause of signing failure) ===")
print("\n".join(missing) if missing else "(none)")
print()
print("=== Keys in profile NOT in binary (unused grants, usually harmless) ===")
print("\n".join(extra) if extra else "(none)")
PY
```

This compares top-level entitlement keys only. Values can also cause failures, for example `aps-environment` of `development` versus `production`, or an Associated Domains entry with a trailing slash. When the key sets match but signing still fails, open `binary.plist` and `profile.plist` side by side.

Run the script in Terminal on the remote Mac, over SSH or the remote desktop. The first block lists every entitlement your binary claims that the profile does not cover, and those are the mismatches to fix. The second block is informational.

## What are the common mismatches and their causes?

**`aps-environment` missing from the profile.** Push Notifications was enabled on the App ID after the profile was generated, or you regenerated the App ID and never re-downloaded the profile. Regenerate the Distribution profile, download it, then archive again.

**`com.apple.developer.icloud-services` rejected.** iCloud entitlements (`CloudKit`, `CloudDocuments`) need iCloud enabled on the App ID *and* a specific CloudKit container listed. A container referenced locally but never created in the portal will not appear in the profile.

**`com.apple.developer.associated-domains` mismatch.** The profile entries must match those in the binary exactly. A trailing slash, an uppercase letter or an extra suffix on one side fails verification, and the diff output shows it directly.

**Extension bundle with the wrong profile.** A Share, Notification Service or Widget extension has its own binary and its own provisioning profile. Inspect it separately:

```bash
codesign -d --entitlements :- Payload/YourApp.app/PlugIns/YourExtension.appex
```

## How do I fix the mismatch?

Once the diff names the offending key:

1. **Enable the capability on the App ID** at [developer.apple.com](https://developer.apple.com) under Certificates, Identifiers & Profiles → Identifiers.
2. **Regenerate** the Distribution provisioning profile for that App ID.
3. **Download** the new profile and either let Xcode consume it or drop it in `~/Library/MobileDevice/Provisioning Profiles/` on the remote Mac.
4. **Re-archive** the app. With manual signing, reference the new profile explicitly.
5. **Re-run the diff** on the new IPA to confirm the fix before you resubmit.

Do not regenerate every profile at once if only one capability is affected. Regenerating changes the profile UUID, which can require updates in your CI configuration.

## Can the Intel Mac VM run the entitlement diff?

Entitlement debugging is command-line work. `codesign`, `security`, `PlistBuddy` and `plutil` are stock on macOS, so the diff above runs unchanged on the [Intel Mac VM](/mac-hosting#intel-vm) ($25 a month, $2 a day). It runs macOS Sequoia with Xcode 26.3 or earlier, which can also cross-compile and sign arm64 device and universal macOS targets. Executing arm64 binaries, Xcode 26.4 or later, or visionOS work needs the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($39 a month, $6 a day) or the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) ($349 a month). Check the macOS version shown before purchase against [Apple's Xcode requirements](https://developer.apple.com/xcode/system-requirements). Signing certificates and CI setup stay your responsibility, and you have administrator access to your own Mac or VM. Compare plans at [/mac-hosting](/mac-hosting).

**Related guides:**
- [Access Xcode GUI Over VNC on a Remote Mac](/blog/mac-vnc-xcode-gui-remote)
- [Run Multiple Xcode Versions on One CI Mac](/blog/mac-multiple-xcode-versions-ci)
- [Run a GitHub Actions Self-Hosted Runner on a Remote Mac](/blog/mac-github-actions-self-hosted-runner)
