Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iHTCboy/cc61cb1ec2349f535a760a346fd6d6ca to your computer and use it in GitHub Desktop.
Save iHTCboy/cc61cb1ec2349f535a760a346fd6d6ca to your computer and use it in GitHub Desktop.
检测 iOS App 是否 TestFlight 下载的 ipa
OC
```
if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
// TestFlight
} else {
// App Store (and Apple reviewers too)
}
BOOL isRunningTestFlightBeta = [[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt"];
```
Swift
```
/// 是否是 testflight包
public static var isTestFlight: Bool {
return isAppStoreReceiptSandbox && !hasEmbeddedMobileProvision
}
/// 是否是 Appstore 包
public static var isAppStore: Bool {
if isAppStoreReceiptSandbox || hasEmbeddedMobileProvision {
return false
}
return true
}
fileprivate static var isAppStoreReceiptSandbox: Bool {
let b = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
NSLog("isAppStoreReceiptSandbox: \(b)")
return b
}
fileprivate static var hasEmbeddedMobileProvision: Bool {
let b = Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") != nil
NSLog("hasEmbeddedMobileProvision: \(b)")
return b
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment