how to check if the build is Testflight or App Store?

I'm using a solution based on this : 

https://stackoverflow.com/questions/26081543/how-to-tell-at-runtime-whether-an-ios-app-is-running-through-a-testflight-beta-i%C2%A0TLDR, checking if Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" 

But this solution is returning true for isTestFlight even when I build the app in Debug.

Replies

I misread the link I shared. Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"  returns true for debug build and testflight build both. But return false for the App Store build. Thanks!