Skip to content

Instantly share code, notes, and snippets.

@nickplee
Last active November 10, 2016 18:26
Show Gist options
  • Save nickplee/b599d727c2d516917e1ea1f6c002468b to your computer and use it in GitHub Desktop.
Save nickplee/b599d727c2d516917e1ea1f6c002468b to your computer and use it in GitHub Desktop.
Detects the type of provisioning profile embedded in your app's bundle
// Inspired by: http://stackoverflow.com/questions/16243855/how-to-detect-that-a-provisioning-profile-is-for-development-or-distribution-pr
static let isDebugBuild: Bool = {
#if (!arch(i386) && !arch(x86_64)) && os(iOS)
guard let profileURL = Bundle.main.url(forResource: "embedded", withExtension: "mobileprovision"), var profileString = try? String(contentsOf: profileURL, encoding: .ascii) else {
return false
}
profileString = profileString.components(separatedBy: .whitespacesAndNewlines).joined()
return profileString.range(of: "<key>get-task-allow</key><true/>") != nil
#else
return true
#endif
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment