问题
In the past I've had separate build configurations for production and beta builds distributed through TestFlight. This made it easy to make modifications to beta builds, such as exposing additional settings the app to let testers test things more thoroughly and see more technical information about the status of the app.
Is there a way to check if an app has been distributed through Apple's TestFlight to make changes to how the app runs? Compiler directives no longer make sense as the same build can be distributed to beta testers and submitted to the store, but perhaps there's a way to check at runtime.
回答1:
This works:
if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
// TestFlight
} else {
// App Store (and Apple reviewers too)
}
Update
The above method doesn't seem to work anymore, Apple changed the way they sign TestFlight builds. This does work however:
BOOL isRunningTestFlightBeta = [[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt"];
来源:https://stackoverflow.com/questions/27297435/detect-if-ios-app-is-downloaded-from-apples-testflight