Detecting TestFlight build on macOS

I currently use this hack to determine a TestFlight build on iOS:

https://stackoverflow.com/a/32238344/784615

Now that TestFlight also supports macOS, I wonder two things:

  • Is there a standard API to detect a TestFlight build? In general, a TestFlight framework would be HIGHLY desirable
  • If not, anyone knows a hack like the above that would work for macOS?

I ask because the in-app receipt is called "receipt" even for TestFlight builds on macOS.

Thanks in advance

Answered by lukaskubanek in 697899022

Hi, I came up with a solution based on the code signing certificate check. According to my early tests, it works reliable. Can you confirm?

Accepted Answer

Hi, I came up with a solution based on the code signing certificate check. According to my early tests, it works reliable. Can you confirm?

If you have In-App Purchases or Subscriptions in your app, you can determine the purchase environment from the Transaction object, which has an environment property. There are three possible values: sandbox, xcode, and production. So you cannot distinguish between development and TestFlight builds. But you can determine when you are not in production. So the combination of !DEBUG and transaction.environment != .production can be used to identify TestFlight users. You just need to get hold of some App Store transaction at some point.

https://developer.apple.com/documentation/storekit/transaction/3963920-environment

Detecting TestFlight build on macOS
 
 
Q