Detect if iOS App is Downloaded from Apple's Testflight

Anthony Mattox picture Anthony Mattox · Dec 4, 2014 · Viewed 7.4k times · Source

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.

Answer

Kevin Renskers picture Kevin Renskers · Dec 10, 2014

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"];