ds: allow one app group on free teams (#284)
- Commit
0c63e6979fd3ebeba3bbd5c8f9eca91142db19ae- Author
- Cesar Andres Pereira Bernal <[email protected]>
- When
- 2026-10-30 06:11 UTC (1 month ago)
- Parents
bca6f59
## What does this PR do? Resolves the FIXME in `DeveloperServicesCapability`: App Groups are no longer filtered out on free teams, and `DeveloperServicesAddAppOperation` assigns at most one group per app on a free team (the constraint the FIXME mentioned). Free teams can register and assign app groups through the Xcode DeveloperServices API (as AltStore/SideStore do), so a widget and its app can share `UserDefaults(suiteName:)` with a free Apple ID. ## How was it tested? Built on Linux from `main` (4d0c429). Installed a Flutter app with a WidgetKit extension on an iPhone (iOS 27.2) with a free Apple ID: the app gets `group.XTL-<team>.<id>` in its entitlements and the widget reads the app's data through it. `make lint` not run (no SwiftLint on this machine). ## AI tool usage How much of this PR was AI-assisted? (check one) - [ ] **0** - No AI was used to write code - [x] **1** - I was assisted by AI. 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * App Groups are now available to free teams. * Apps assigned to multiple App Groups are rejected with a clear error message. * Invalid app errors now include the app’s URL path, making it easier to identify which app could not be added. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Kabir Oberai <[email protected]>
Diff
Sources/XKit/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift
diff --git a/Sources/XKit/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift b/Sources/XKit/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swiftindex d726e91..c2b5f51 100644--- a/Sources/XKit/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift +++ b/Sources/XKit/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift @@ -11,19 +11,23 @@ import DeveloperAPI public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation { - public enum Error: LocalizedError {+ public enum Error: LocalizedError, CustomStringConvertible { case invalidApp(URL)+ case tooManyAppGroups(bundleID: String, groups: [DeveloperServicesAppGroup.GroupID]) public var errorDescription: String? {+ description+ }++ public var description: String { switch self { case .invalidApp(let url):- return url.path.withCString {- String.localizedStringWithFormat(- NSLocalizedString(- "add_app_operation.error.invalid_app", value: "Invalid app: %s", comment: ""- ), $0- )- }+ "Invalid app: \(url.path)"+ case .tooManyAppGroups(let bundleID, let groups):+ """+ App '\(bundleID)' requests multiple app groups: \(groups.map(\.rawValue).joined(separator: ", ")), \+ which is not permitted when using a free team.+ """ } } }@@ -180,6 +184,10 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation { // re-assign rather than using updateEntitlements since the latter will // retain unrecognized entitlements let filtered = try entitlements.entitlements().filter { $0.anyCapability?.isFree != false }+ if let groups = filtered.lazy.compactMap({ $0 as? AppGroupEntitlement }).first?.rawValue,+ groups.count > 1 {+ throw Error.tooManyAppGroups(bundleID: bundleID, groups: groups)+ } entitlements = try Entitlements(entitlements: filtered) } } else {
Sources/XKit/DeveloperServices/App IDs/Entitlements/DeveloperServicesCapability.swift
diff --git a/Sources/XKit/DeveloperServices/App IDs/Entitlements/DeveloperServicesCapability.swift b/Sources/XKit/DeveloperServices/App IDs/Entitlements/DeveloperServicesCapability.swiftindex 1d12254..05aad38 100644--- a/Sources/XKit/DeveloperServices/App IDs/Entitlements/DeveloperServicesCapability.swift +++ b/Sources/XKit/DeveloperServices/App IDs/Entitlements/DeveloperServicesCapability.swift @@ -73,9 +73,7 @@ extension DataProtectionEntitlement: EntitlementWithCapability { extension AppGroupEntitlement: EntitlementWithCapability { var capability: DeveloperServicesCapability {- // FIXME: Enable app groups on free accounts- // but we need to always assign only one group- DeveloperServicesCapability(.appGroups, isFree: false)+ DeveloperServicesCapability(.appGroups, isFree: true) } }