cove icon indicating copy to clipboard operation
cove copied to clipboard

Validate TestFlight archive entitlements

Open praveenperera opened this issue 5 months ago • 2 comments

Summary

  • Sign TestFlight archives during the archive step so target entitlements survive into the uploaded build
  • Validate the archived app's signed entitlements locally before upload
  • Document the iCloud Drive/TestFlight failure mode and why the check matters

praveenperera avatar Jun 12 '26 19:06 praveenperera

[!IMPORTANT]

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4208e044-633e-4b91-9d03-2240e849e19f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • [ ] 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Commit unit tests in branch fix-just-testflight

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jun 12 '26 19:06 coderabbitai[bot]

Greptile Summary

This PR fixes a TestFlight signing regression by setting CODE_SIGN_IDENTITY to "Apple Distribution" at archive time (previously "") so that target entitlements survive into the uploaded build, and adds a pre-upload validation step that inspects the signed archive's entitlements with codesign -d.

  • rust/xtask/src/ios.rs: Changes IOS_TESTFLIGHT_CODE_SIGN_IDENTITY from "" to "Apple Distribution", adds IOS_REQUIRED_SIGNED_ENTITLEMENTS (four iCloud/NFC/associated-domains keys), and introduces validate_testflight_archive_entitlements which runs codesign -d --entitlements - on the archived .app and bails if any required entitlement is absent.
  • docs/icloud_drive.md: Adds a "TestFlight signing" subsection explaining why unsigned archives can silently strip target entitlements and how the new local check surfaces the failure before upload.

Confidence Score: 3/5

The core goal is sound, but the validation function will error on every correctly-signed archive due to the binary-plist output issue, so in its current form it blocks all TestFlight uploads rather than guarding them.

The validate_testflight_archive_entitlements function calls String::from_utf8 on codesign's stdout, which carries a binary plist blob that is not guaranteed to be valid UTF-8. A typical bplist00 header and offset table contain non-ASCII bytes that will cause from_utf8 to return Err, surfacing as "Failed to parse codesign entitlement stdout" on every signed archive — meaning the new guard will fail the upload even when signing is entirely correct. The CODE_SIGN_IDENTITY change and the overall structure of the validation are correct; only the stdout-parsing call needs to switch to from_utf8_lossy.

rust/xtask/src/ios.rs — specifically the stdout/stderr parsing in validate_testflight_archive_entitlements

Important Files Changed

Filename Overview
rust/xtask/src/ios.rs Adds TestFlight archive entitlement validation and changes CODE_SIGN_IDENTITY to "Apple Distribution"; the new validation function uses String::from_utf8 on codesign's stdout, which can fail on binary-plist output and block all uploads
docs/icloud_drive.md Adds a "TestFlight signing" subsection documenting why archives must be signed at archive time for target entitlements to survive; documentation only, no logic concerns

Sequence Diagram

sequenceDiagram
    participant J as just testflight
    participant X as xcodebuild archive
    participant V as validate_testflight_archive_entitlements
    participant C as codesign -d
    participant E as xcodebuild exportArchive

    J->>X: "CODE_SIGN_IDENTITY=Apple Distribution archive"
    X-->>J: .xcarchive (signed)
    J->>V: validate archive entitlements
    V->>C: /usr/bin/codesign -d --entitlements - Cove.app
    C-->>V: entitlements blob (stdout) + diagnostics (stderr)
    alt unsigned or missing entitlements
        V-->>J: bail! (blocks upload)
    else all required entitlements present
        V-->>J: Ok(())
        J->>E: exportArchive + upload to App Store Connect
        E-->>J: success
    end

Reviews (1): Last reviewed commit: "Require signed TestFlight entitlements" | Re-trigger Greptile

greptile-apps avatar Jun 12 '26 20:06 greptile-apps