Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {

public enum Error: LocalizedError {
case invalidApp(URL)
case tooManyAppGroups(bundleID: String, count: Int)

public var errorDescription: String? {
switch self {
Expand All @@ -24,6 +25,16 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {
), $0
)
}
case .tooManyAppGroups(let bundleID, let count):
return bundleID.withCString {
String.localizedStringWithFormat(
NSLocalizedString(
"add_app_operation.error.too_many_app_groups",
value: "%s requests %d app groups, but free teams can only use one app group per app",
comment: ""
), $0, count
)
}
}
}
}
Expand Down Expand Up @@ -180,6 +191,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, count: groups.count)
}
entitlements = try Entitlements(entitlements: filtered)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down