8

In the prior test flight system we pushed AdHoc builds which we used a compiler constant to identify to turn on/off features for our beta testers. Now with Apple's Beta Test Flight System we have to build for the App Store, i.e. not AdHoc, which is fine as if it tests good we can use the same build for a production review.

Is there any way from within iOS to detect that the build is a Test Flight delivered build so we know "this is beta" and do the same as before with the AdHoc compiler constant?

Thank you

Allen
  • 6,745
  • 5
  • 41
  • 59
Neal
  • 9,487
  • 15
  • 58
  • 101
  • Check out these answers: http://stackoverflow.com/questions/12431994/detect-testflight http://stackoverflow.com/questions/27297435/detect-if-ios-app-is-downloaded-from-apples-testflight – Adam Ivancza Feb 03 '15 at 09:45
  • 1
    possible duplicate of [How to tell at runtime whether an iOS app is running through a TestFlight Beta install](http://stackoverflow.com/questions/26081543/how-to-tell-at-runtime-whether-an-ios-app-is-running-through-a-testflight-beta-i) – combinatorial Feb 03 '15 at 18:28
  • 1
    This looks promising: https://twitter.com/tapbot_paul/status/557551769496997888 – John Gibb Jun 08 '15 at 21:57

2 Answers2

2

There is one way that I use it for my projects.

In Xcode, go to the the project settings (project, not target) and add "beta" configuration to the list:

enter image description here



Then you need to create new scheme that will run project in "beta" configuration. To create scheme go here:

enter image description here



Name this scheme whatever you want. The you should edit settings for this scheme. To do this, tap here:

enter image description here



Select Archive tab where you can select Build configuration

enter image description here



Then you need to add a key Config with value $(CONFIGURATION) the projects info property list like this:

enter image description here



Then its just the matter what you need in code to do something specific to beta build:

let config = Bundle.main.object(forInfoDictionaryKey: "Config") as! String
if config == "Debug" {
  // app running in debug configuration
}
else if config == "Release" {
  // app running in release configuration
}
else if config == "Beta" {
  // app running in beta configuration
}
Klemen
  • 2,144
  • 2
  • 23
  • 31
0

Here's a simple and useful function you can use in any app to easily check if the running app was installed by TestFlight:

func isTestFlight() -> Bool {
    guard let path = Bundle.main.appStoreReceiptURL?.path else {
        return false
    }
    return path.contains("sandboxReceipt")
}

No need to create special build configs, schemes, etc.

Gsp
  • 401
  • 5
  • 10