How to install Application via Test Flight in IOS ?

I found something on how to install Application via Test Flight in IOS .

Here, appStoreReceiptURL is an instance property, which we can find from main bundle.

Here, I am adding snippet for both Objective-C and Swift.

Objective-C

- (BOOL)isTestFlight {
NSURL *appStoreReceiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
if (appStoreReceiptURL != NULL) {
return [appStoreReceiptURL.lastPathComponent isEqualToString:@"sandboxReceipt"];
}
return NO;
}
- (BOOL)isTestFlight {
NSURL *appStoreReceiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
if (appStoreReceiptURL != NULL) {
return [appStoreReceiptURL.lastPathComponent isEqualToString:@"sandboxReceipt"];
}
return NO;
}

Swift

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