I would like to detect if a given provisioning profile is a development profile or a distribution (adhoc or app store) profile. I need to do this purely programmatically. >
Here is a version for Swift 3, based on @steipete's answer:
static func isDevelopmentProvisioningProfile() -> Bool {
#if IOS_SIMULATOR
return true
#else
// there will be no provisioning profile in AppStore Apps
guard let fileName = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") else {
return false
}
let fileURL = URL(fileURLWithPath: fileName)
// the documentation says this file is in UTF-8, but that failed
// on my machine. ASCII encoding worked ¯\_(ツ)_/¯
guard let data = try? String(contentsOf: fileURL, encoding: .ascii) else {
return false
}
let cleared: String = data.components(separatedBy: .whitespacesAndNewlines).joined()
return cleared.contains("get-task-allow ")
#endif
}
If curious, get-task-allow
is a flag that the build uses to determine whether you should be able to hook up a debugger and other processes like that - so it's quite accurate for whether it is a dev build or no.