Skip to content

Commit f29f6ba

Browse files
authored
Clean up some entitlements code (#165)
- We already do the `isFree` declarations in `DeveloperServiceCapability.swift`. Don't need to duplicate it on the entitlement types. - Add support for creating capabilities with raw names
1 parent 430cbd1 commit f29f6ba

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

Sources/XKit/DeveloperServices/App IDs/Entitlements/DeveloperServicesCapability.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ public struct DeveloperServicesCapability: Sendable, Hashable {
2323
self.isFree = isFree
2424
self.settings = settings
2525
}
26+
27+
public init(
28+
rawName: String,
29+
isFree: Bool,
30+
settings: [Components.Schemas.CapabilitySetting]? = nil
31+
) {
32+
self.capabilityType = .init(value2: rawName)
33+
self.isFree = isFree
34+
self.settings = settings
35+
}
2636
}
2737

2838
protocol EntitlementWithCapability: Entitlement {

Sources/XKit/Model/Entitlements/EntitlementTypes.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,20 @@ extension EntitlementContainer {
3333

3434
public struct ApplicationIdentifierEntitlement: Entitlement, RawRepresentable {
3535
public static let identifier = "application-identifier"
36-
public static let isFree = true
3736

3837
public var rawValue: String
3938
public init(rawValue: String) { self.rawValue = rawValue }
4039
}
4140

4241
public struct TeamIdentifierEntitlement: Entitlement, RawRepresentable {
4342
public static let identifier = "com.apple.developer.team-identifier"
44-
public static let isFree = true
4543

4644
public var rawValue: String
4745
public init(rawValue: String) { self.rawValue = rawValue }
4846
}
4947

5048
public struct KeychainAccessGroupsEntitlement: Entitlement, RawRepresentable {
5149
public static let identifier = "keychain-access-groups"
52-
public static let isFree = true
5350

5451
public var rawValue: [String]
5552
public init(rawValue: [String]) { self.rawValue = rawValue }
@@ -66,10 +63,6 @@ public struct KeychainAccessGroupsEntitlement: Entitlement, RawRepresentable {
6663

6764
public struct AppGroupEntitlement: Entitlement, RawRepresentable {
6865
public static let identifier = "com.apple.security.application-groups"
69-
// FIXME: Enable app groups on free accounts
70-
// but first we need to fix the bug where it only assigns one
71-
// app group even if the ents say there are multiple
72-
public static let isFree = false
7366

7467
public var rawValue: [DeveloperServicesAppGroup.GroupID]
7568
public init(rawValue: [DeveloperServicesAppGroup.GroupID]) { self.rawValue = rawValue }
@@ -85,15 +78,13 @@ public struct AppGroupEntitlement: Entitlement, RawRepresentable {
8578

8679
public struct GetTaskAllowEntitlement: Entitlement, RawRepresentable {
8780
public static let identifier = "get-task-allow"
88-
public static let isFree = true
8981

9082
public var rawValue: Bool
9183
public init(rawValue: Bool) { self.rawValue = rawValue }
9284
}
9385

9486
public struct AssociatedDomainsEntitlement: Entitlement, RawRepresentable {
9587
public static let identifier = "com.apple.developer.associated-domains"
96-
public static let isFree = false
9788

9889
public var rawValue: [String]
9990
public init(rawValue: [String]) { self.rawValue = rawValue }
@@ -109,15 +100,13 @@ public struct AssociatedDomainsEntitlement: Entitlement, RawRepresentable {
109100

110101
public enum APSEnvironmentEntitlement: String, Entitlement {
111102
public static let identifier = "aps-environment"
112-
public static let isFree = false
113103

114104
case development
115105
case production
116106
}
117107

118108
public enum DataProtectionEntitlement: String, Entitlement {
119109
public static let identifier = "com.apple.developer.default-data-protection"
120-
public static let isFree = true
121110

122111
case complete = "NSFileProtectionComplete"
123112
case unlessOpen = "NSFileProtectionCompleteUnlessOpen"
@@ -126,63 +115,55 @@ public enum DataProtectionEntitlement: String, Entitlement {
126115

127116
public struct NetworkExtensionEntitlement: Entitlement, RawRepresentable {
128117
public static let identifier = "com.apple.developer.networking.networkextension"
129-
public static let isFree = false
130118

131119
public var rawValue: Bool
132120
public init(rawValue: Bool) { self.rawValue = rawValue }
133121
}
134122

135123
public struct MultipathEntitlement: Entitlement, RawRepresentable {
136124
public static let identifier = "com.apple.developer.networking.multipath"
137-
public static let isFree = false
138125

139126
public var rawValue: Bool
140127
public init(rawValue: Bool) { self.rawValue = rawValue }
141128
}
142129

143130
public struct VPNConfigurationEntitlement: Entitlement, RawRepresentable {
144131
public static let identifier = "com.apple.networking.vpn.configuration"
145-
public static let isFree = false
146132

147133
public var rawValue: Bool
148134
public init(rawValue: Bool) { self.rawValue = rawValue }
149135
}
150136

151137
public struct SiriKitEntitlement: Entitlement, RawRepresentable {
152138
public static let identifier = "com.apple.developer.siri"
153-
public static let isFree = false
154139

155140
public var rawValue: Bool
156141
public init(rawValue: Bool) { self.rawValue = rawValue }
157142
}
158143

159144
public struct InterAppAudioEntitlement: Entitlement, RawRepresentable {
160145
public static let identifier = "inter-app-audio"
161-
public static let isFree = true
162146

163147
public var rawValue: Bool
164148
public init(rawValue: Bool) { self.rawValue = rawValue }
165149
}
166150

167151
public struct WirelessAccessoryEntitlement: Entitlement, RawRepresentable {
168152
public static let identifier = "com.apple.external-accessory.wireless-configuration"
169-
public static let isFree = true
170153

171154
public var rawValue: Bool
172155
public init(rawValue: Bool) { self.rawValue = rawValue }
173156
}
174157

175158
public struct HomeKitEntitlement: Entitlement, RawRepresentable {
176159
public static let identifier = "com.apple.developer.homekit"
177-
public static let isFree = true
178160

179161
public var rawValue: Bool
180162
public init(rawValue: Bool) { self.rawValue = rawValue }
181163
}
182164

183165
public struct HealthKitEntitlement: Entitlement, RawRepresentable {
184166
public static let identifier = "com.apple.developer.healthkit"
185-
public static let isFree = true
186167

187168
public var rawValue: Bool
188169
public init(rawValue: Bool) { self.rawValue = rawValue }

0 commit comments

Comments
 (0)