Thanks @DTS Engineer for the detailed snippet.
The usage of get-task-allow entitlement gave me idea for updating my previous parsing entitlement approach and I came up with this:
struct MobileProvision: Codable {
static let current: MobileProvision = {
let profileExtension = "mobileprovision"
guard
let profilePath = Bundle.main.path(forResource: "embedded", ofType: profileExtension),
let profileString = try? String(contentsOfFile: profilePath, encoding: .isoLatin1),
case let scanner = Scanner(string: profileString),
scanner.scanUpToString("<plist") != nil,
let extractedPlist = scanner.scanUpToString("</plist>"),
let plist = extractedPlist.appending("</plist>").data(using: .isoLatin1)
else { return .simulatorDefault() }
let decoder = PropertyListDecoder()
do {
return try decoder.decode(MobileProvision.self, from: plist)
} catch {
return .simulatorDefault()
}
}()
static func simulatorDefault() -> Self {
return Self(entitlements: Entitlements(isDebuggable: true, apsEnvironment: .development))
}
let entitlements: Entitlements
enum CodingKeys: String, CodingKey {
case entitlements = "Entitlements"
}
struct Entitlements: Codable {
let isDebuggable: Bool
let apsEnvironment: APSEnvironment
enum APSEnvironment: String, Codable {
case development, production
}
enum CodingKeys: String, CodingKey {
case isDebuggable = "get-task-allow"
case apsEnvironment = "aps-environment"
}
}
}
This snippet has the same drawback as your snippet in the sense that it will not work on simulators (which is an acceptable compromise for me), but this works with tvOS as well (which is more priority for me than macOS). Do you think any drawback for this approach?
Personally the one drawback I see is this relies on un-documented provisioning profile structure which might break in future if Apple changes it but I doubt that will ever happen.
I will try to compare performance of both approaches and come up with some numbers.