| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | profile="$1" |
| 5 | team="$2" |
| 6 | output="$3" |
| 7 | bundle_id=io.github.lee-xeo.claude-cage |
| 8 | [[ "$team" =~ ^[A-Z0-9]{10}$ ]] || { echo 'A valid Developer ID team is required.' >&2; exit 1; } |
| 9 | security cms -D -i "$profile" -o "$output.profile.plist" |
| 10 | profile_team=$(/usr/libexec/PlistBuddy -c 'Print :TeamIdentifier:0' "$output.profile.plist") |
| 11 | profile_app=$(/usr/libexec/PlistBuddy -c 'Print :Entitlements:com.apple.application-identifier' "$output.profile.plist") |
| 12 | [[ "$profile_team" == "$team" && "$profile_app" == "$team.$bundle_id" ]] || { echo 'Provisioning profile does not match the signing team and Cage bundle.' >&2; exit 1; } |
| 13 | cat > "$output" <<PLIST |
| 14 | <?xml version="1.0" encoding="UTF-8"?> |
| 15 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 16 | <plist version="1.0"><dict> |
| 17 | <key>com.apple.application-identifier</key><string>$team.$bundle_id</string> |
| 18 | <key>com.apple.developer.team-identifier</key><string>$team</string> |
| 19 | <key>keychain-access-groups</key><array><string>$team.$bundle_id</string></array> |
| 20 | </dict></plist> |
| 21 | PLIST |