Skip to content

ds: keep the team's keychain access groups when signing - #444

Open
gulian wants to merge 1 commit into
xtool-org:mainfrom
gulian:ds-keychain-groups
Open

gulian wants to merge 1 commit into
xtool-org:mainfrom
gulian:ds-keychain-groups

Conversation

@gulian

@gulian gulian commented Nov 14, 2026 •

Copy link
Copy Markdown

What does this PR do?

Keeps the keychain access groups an app asks for when it is signed for development, as long as they belong to the team.

Entitlements.update(teamID:bundleID:) replaces keychain-access-groups with the app's own group (<team>.<bundle id>). An app and an extension that both list a common group to share keychain items (<team>.com.example.shared) each end up with only their own group. Nothing is reported at build or install time; at runtime every query that names the shared group fails with -34018 (errSecMissingEntitlement).

With an App Store Connect API key this is the only way an app can share data with its extensions, since app groups can't be assigned there (see #324).

After this change the signed groups are the app's own group, followed by the requested groups that start with <team>.. Groups of another team, wildcards and unresolved $(AppIdentifierPrefix) values are dropped, as before. The own group stays first on purpose: items added without an explicit group go to the first one, so apps that install today keep storing their items where they already are.

No provisioning change is needed: the development profile already grants <team>.*.

Related: #326 keeps a <team>.shared group when signing for distribution, so this brings development signing in line with it. #324 leaves keychain-access-groups untouched, so the two should compose.

How was it tested?

  • Unit tests in KeychainAccessGroupsTests.swift: the default (own group only), shared groups kept with the own group first whatever the input order, and what gets dropped. Two of the three fail on main. swift test on Linux (Ubuntu 26.04, Swift 6.4.1): 64 tests pass.
  • On a device: a tvOS app and its Top Shelf extension sharing one keychain group, signed with xtool dev build --sign (paid team, App Store Connect API key) and installed on an Apple TV on tvOS 27.2. Both signed binaries list their own group, then the shared one. The app writes an item in the shared group and the extension reads it. Items the app had stored before, without a group, are still readable. That run used the same merge placed in addApp on top of build: support tvOS, macOS, and Mac Catalyst apps #362; I moved it into update afterwards to make it testable.
  • Not tested: an iOS device, macOS. make lint could not run on my host (the SwiftLint binary needs libxml2.so.2).

AI tool usage

How much of the code in this PR was AI-assisted? (check one)

  • 0 - No AI was used to write code
  • 1 - I was assisted by AI in writing code. I reviewed the finished result.
  • 2 - I set the AI going and left it to it; nobody has read the result - no review, or AI review only

Summary by CodeRabbit

  • Bug Fixes
    • Updating team or bundle identifiers now retains eligible team-shared keychain access groups. The app’s own group stays first, existing order is preserved, and duplicate, wildcard, or differently prefixed groups are excluded. If there are no eligible groups or no keychain access-group entitlement, the existing behavior remains unchanged.

Development signing replaced keychain-access-groups with the app's own
group, so an app and its extensions could not share a keychain group.
Keep the groups the build asks for when they belong to the team, after
the app's own group, which stays the default for items added without one.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The entitlement update retains qualifying team-shared keychain access groups when it replaces team-or-bundle-ID entitlements. Tests cover the app’s own group, valid shared groups, and groups excluded by prefix, wildcard, or duplication.

Changes: Keychain Access Group Preservation

Layer / File(s) Summary
Preserve and test keychain access groups
Sources/XKit/DeveloperServices/App IDs/Entitlements/EntitlementWithTeamOrBundleID.swift, Tests/XToolTests/KeychainAccessGroupsTests.swift
The update retains unique, non-wildcard groups that begin with the selected team ID and keeps the app’s own group first. Tests cover missing and empty requests, valid shared groups, and excluded groups.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 55267

This change keeps team-owned shared keychain access groups during development signing while the app's own group stays first. The scope is narrow and unit tests cover the main cases, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "ds: keep the team's keychain access groups when signing" matches the main change. The PR makes Entitlements.update(teamID:bundleID:) retain existing keychain access groups that start with t…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "ds: keep the team's keychain access groups when signing" matches the main change. The PR makes Entitlements.update(teamID:bundleID:) retain existing keychain access groups that start with the team ID, appending them after the app's own group during development signing. The title names the team-ID-prefixed keychain access groups and the signing context, so it describes the primary change. The "ds:" prefix is a scope tag and does not affect the assessment.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4e7daaba-8d4e-447d-9d60-322cefc02102
Commits

Reviewing files that changed from the base of the PR and between a2875dd and 55267d6.

Files selected for processing: 2

  • Sources/XKit/DeveloperServices/App IDs/Entitlements/EntitlementWithTeamOrBundleID.swift
  • Tests/XToolTests/KeychainAccessGroupsTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant