Skip to content

Commit b292371

Browse files
committed
test an alternative method for isTestFlightBuild
1 parent 211a337 commit b292371

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Loop/Managers/AppExpirationAlerter.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class AppExpirationAlerter {
104104
formatter.unitsStyle = .full
105105
formatter.zeroFormattingBehavior = .dropLeading
106106
formatter.maximumUnitCount = maxUnitCount
107-
return formatter;
107+
return formatter
108108
}
109109

110110
static func buildDate() -> Date? {
@@ -122,9 +122,23 @@ class AppExpirationAlerter {
122122
}
123123

124124
static func isTestFlightBuild() -> Bool {
125-
return BuildDetails.default.isGitHubBuild ?? false
125+
// If an "embedded.mobileprovision" is present in the main bundle, then
126+
// this is an Xcode, Ad-Hoc, or Enterprise distribution. Return false.
127+
if Bundle.main.url(forResource: "embedded", withExtension: "mobileprovision") != nil {
128+
return false
129+
}
130+
131+
// If an app store receipt is not present in the main bundle, then we cannot
132+
// say whether this is a TestFlight or App Store distribution. Return false.
133+
guard let receiptName = Bundle.main.appStoreReceiptURL?.lastPathComponent else {
134+
return false
135+
}
136+
137+
// A TestFlight distribution presents a "sandboxReceipt", while an App Store
138+
// distribution presents a "receipt". Return true if we have a TestFlight receipt.
139+
return "sandboxReceipt".caseInsensitiveCompare(receiptName) == .orderedSame
126140
}
127-
141+
128142
static func calculateExpirationDate(profileExpiration: Date) -> Date {
129143
let isTestFlight = isTestFlightBuild()
130144

0 commit comments

Comments
 (0)