Skip to content

Commit 7434377

Browse files
authored
Removed Unused Availability Checks (#13023)
1 parent d91a5bc commit 7434377

File tree

11 files changed

+45
-106
lines changed

11 files changed

+45
-106
lines changed

FirebaseAppDistribution/Sources/FIRAppDistributionUIService.m

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@
2323

2424
@implementation FIRAppDistributionUIService
2525

26-
API_AVAILABLE(ios(9.0))
27-
SFSafariViewController *_safariVC;
28-
2926
API_AVAILABLE(ios(12.0))
3027
ASWebAuthenticationSession *_webAuthenticationVC;
3128

32-
API_AVAILABLE(ios(11.0))
29+
// TODO: Remove this when the deployment target becomes iOS 12+
3330
SFAuthenticationSession *_safariAuthenticationVC;
3431

3532
- (instancetype)init {
@@ -74,7 +71,7 @@ + (NSError *_Nullable)mapErrorToAppDistributionError:(NSError *_Nullable)error {
7471
if ([error code] == ASWebAuthenticationSessionErrorCodeCanceledLogin) {
7572
return [self getAppDistributionError:FIRAppDistributionErrorAuthenticationCancelled];
7673
}
77-
} else if (@available(iOS 11.0, *)) {
74+
} else {
7875
if ([error code] == SFAuthenticationErrorCanceledLogin) {
7976
return [self getAppDistributionError:FIRAppDistributionErrorAuthenticationCancelled];
8077
}
@@ -110,7 +107,7 @@ - (void)appDistributionRegistrationFlow:(NSURL *)URL
110107
_webAuthenticationVC = authenticationVC;
111108

112109
[authenticationVC start];
113-
} else if (@available(iOS 11.0, *)) {
110+
} else {
114111
_safariAuthenticationVC = [[SFAuthenticationSession alloc]
115112
initWithURL:URL
116113
callbackURLScheme:callbackURL
@@ -123,13 +120,6 @@ - (void)appDistributionRegistrationFlow:(NSURL *)URL
123120
}];
124121

125122
[_safariAuthenticationVC start];
126-
} else if (@available(iOS 9.0, *)) {
127-
SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:URL];
128-
129-
safariVC.delegate = self;
130-
_safariVC = safariVC;
131-
[self->_safariHostingViewController presentViewController:safariVC animated:YES completion:nil];
132-
self.registrationFlowCompletion = completion;
133123
}
134124
}
135125

@@ -244,16 +234,16 @@ - (void)resetUIState {
244234

245235
self.registrationFlowCompletion = nil;
246236

247-
if (@available(iOS 11.0, *)) {
248-
_safariAuthenticationVC = nil;
249-
} else if (@available(iOS 12.0, *)) {
237+
if (@available(iOS 12.0, *)) {
250238
_webAuthenticationVC = nil;
251-
} else if (@available(iOS 9.0, *)) {
252-
_safariVC = nil;
253239
}
240+
// TODO: Remove this when the deployment target becomes iOS 12+
241+
// `_safariAuthenticationVC` is cleared unconditionally just in case;
242+
// It’s supposed to be assigned only when run on iOS 11.
243+
_safariAuthenticationVC = nil;
254244
}
255245

256-
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller NS_AVAILABLE_IOS(9.0) {
246+
- (void)safariViewControllerDidFinish:(SFSafariViewController *)controller {
257247
NSError *error =
258248
[[self class] getAppDistributionError:FIRAppDistributionErrorAuthenticationCancelled];
259249
[self logRegistrationCompletion:error authType:[SFSafariViewController description]];

FirebaseAuth/Tests/Unit/FIRAuthTests.m

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,19 +2938,15 @@ - (void)testAppDidReceiveRemoteNotificationWithCompletion_NotificationManagerHan
29382938
}
29392939

29402940
- (void)testAppOpenURL_AuthPresenterCanHandleURL {
2941-
if (@available(iOS 9.0, *)) {
2942-
// 'application:openURL:options:' is only available on iOS 9.0 or newer.
2943-
NSURL *url = [NSURL URLWithString:@"https://localhost"];
2941+
NSURL *url = [NSURL URLWithString:@"https://localhost"];
29442942

2945-
OCMExpect([self.mockAuthURLPresenter canHandleURL:url]).andReturn(YES);
2943+
OCMExpect([self.mockAuthURLPresenter canHandleURL:url]).andReturn(YES);
29462944

2947-
XCTAssertTrue([self.fakeApplicationDelegate
2948-
application:[GULAppDelegateSwizzler sharedApplication]
2949-
openURL:url
2950-
options:@{}]);
2945+
XCTAssertTrue([self.fakeApplicationDelegate application:[GULAppDelegateSwizzler sharedApplication]
2946+
openURL:url
2947+
options:@{}]);
29512948

2952-
[self.mockAuthURLPresenter verify];
2953-
}
2949+
[self.mockAuthURLPresenter verify];
29542950
}
29552951

29562952
- (void)testAppOpenURLWithSourceApplication_AuthPresenterCanHandleURL {

FirebaseDatabase/Tests/Integration/FIRDatabaseTests.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,7 @@ - (void)testCallbackQueue {
453453
__block BOOL done = NO;
454454
[database.reference.childByAutoId observeSingleEventOfType:FIRDataEventTypeValue
455455
withBlock:^(FIRDataSnapshot *snapshot) {
456-
if (@available(iOS 10.0, macOS 10.12, *)) {
457-
dispatch_assert_queue(callbackQueue);
458-
} else {
459-
NSAssert(YES, @"Test requires iOS 10");
460-
}
456+
dispatch_assert_queue(callbackQueue);
461457
done = YES;
462458
}];
463459
WAIT_FOR(done);

FirebaseDynamicLinks/Sources/FIRDLDefaultRetrievalProcessV2.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ - (void)handleRetrievalProcessWithResult:(FIRDLRetrievalProcessResult *)result {
176176
- (nullable NSURL *)uniqueMatchLinkToCheck {
177177
_clipboardContentAtMatchProcessStart = nil;
178178
NSString *pasteboardContents = [self retrievePasteboardContents];
179+
if (!pasteboardContents) {
180+
return nil;
181+
}
179182
NSInteger linkStringMinimumLength =
180183
expectedCopiedLinkStringSuffix.length + /* ? or & */ 1 + /* http:// */ 7;
181184
if ((pasteboardContents.length >= linkStringMinimumLength) &&
@@ -201,21 +204,17 @@ - (nullable NSURL *)uniqueMatchLinkToCheck {
201204
return nil;
202205
}
203206

204-
- (NSString *)retrievePasteboardContents {
207+
- (nullable NSString *)retrievePasteboardContents {
205208
if (![self isPasteboardRetrievalEnabled]) {
206209
// Pasteboard check for dynamic link is disabled by user.
207-
return @"";
210+
return nil;
208211
}
209212

210-
NSString *pasteboardContents = @"";
211-
if (@available(iOS 10.0, *)) {
212-
if ([[UIPasteboard generalPasteboard] hasURLs]) {
213-
pasteboardContents = [UIPasteboard generalPasteboard].string;
214-
}
213+
if ([[UIPasteboard generalPasteboard] hasURLs]) {
214+
return [UIPasteboard generalPasteboard].string;
215215
} else {
216-
pasteboardContents = [UIPasteboard generalPasteboard].string;
216+
return nil;
217217
}
218-
return pasteboardContents;
219218
}
220219

221220
/**

FirebaseInAppMessaging/Sources/Analytics/FIRIAMClearcutLogStorage.m

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,11 @@ - (void)loadFromCachePath:(NSString *)cacheFilePath {
167167
id fetchedClearcutRetryRecords;
168168
NSData *data = [NSData dataWithContentsOfFile:filePath];
169169
if (data) {
170-
if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
171-
fetchedClearcutRetryRecords = [NSKeyedUnarchiver
172-
unarchivedObjectOfClasses:[NSSet setWithObjects:[FIRIAMClearcutLogRecord class],
173-
[NSMutableArray class], nil]
174-
fromData:data
175-
error:nil];
176-
} else {
177-
// Fallback on earlier versions
178-
#pragma clang diagnostic push
179-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
180-
fetchedClearcutRetryRecords = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
181-
#pragma clang diagnostic pop
182-
}
170+
fetchedClearcutRetryRecords = [NSKeyedUnarchiver
171+
unarchivedObjectOfClasses:[NSSet setWithObjects:[FIRIAMClearcutLogRecord class],
172+
[NSMutableArray class], nil]
173+
fromData:data
174+
error:nil];
183175
}
184176
if (fetchedClearcutRetryRecords) {
185177
@synchronized(self) {

FirebaseInAppMessaging/Sources/Flows/FIRIAMActivityLogger.m

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,11 @@ - (void)loadFromCachePath:(NSString *)cacheFilePath {
155155
id fetchedActivityRecords;
156156
NSData *data = [NSData dataWithContentsOfFile:filePath];
157157
if (data) {
158-
if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, *)) {
159-
fetchedActivityRecords = [NSKeyedUnarchiver
160-
unarchivedObjectOfClasses:[NSSet setWithObjects:[FIRIAMActivityRecord class],
161-
[NSMutableArray class], nil]
162-
fromData:data
163-
error:nil];
164-
} else {
165-
// Fallback on earlier versions
166-
#pragma clang diagnostic push
167-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
168-
fetchedActivityRecords = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
169-
#pragma clang diagnostic pop
170-
}
158+
fetchedActivityRecords = [NSKeyedUnarchiver
159+
unarchivedObjectOfClasses:[NSSet setWithObjects:[FIRIAMActivityRecord class],
160+
[NSMutableArray class], nil]
161+
fromData:data
162+
error:nil];
171163
}
172164
if (fetchedActivityRecords) {
173165
@synchronized(self) {

FirebaseMLModelDownloader/Sources/FileDownloader.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ class ModelFileDownloader: NSObject, FileDownloader {
6363
self.conditions = conditions
6464
configuration = URLSessionConfiguration.ephemeral
6565
/// Wait for network connectivity.
66-
if #available(iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0, *) {
67-
self.configuration.waitsForConnectivity = true
68-
/// Wait for 10 minutes.
69-
self.configuration.timeoutIntervalForResource = 600
70-
}
66+
configuration.waitsForConnectivity = true
67+
/// Wait for 10 minutes.
68+
configuration.timeoutIntervalForResource = 600
7169
configuration.allowsCellularAccess = conditions.allowsCellularAccess
7270
}
7371

FirebaseMLModelDownloader/Sources/ModelInfoRetriever.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -523,18 +523,10 @@ extension ModelInfoRetriever {
523523

524524
/// Parse date from string - used to get download URL expiry time.
525525
private static func getDateFromString(_ strDate: String) -> Date? {
526-
if #available(iOS 11, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0, *) {
527-
let dateFormatter = ISO8601DateFormatter()
528-
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
529-
dateFormatter.formatOptions = [.withFractionalSeconds]
530-
return dateFormatter.date(from: strDate)
531-
} else {
532-
let dateFormatter = DateFormatter()
533-
dateFormatter.locale = Locale(identifier: "en-US_POSIX")
534-
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
535-
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
536-
return dateFormatter.date(from: strDate)
537-
}
526+
let dateFormatter = ISO8601DateFormatter()
527+
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
528+
dateFormatter.formatOptions = [.withFractionalSeconds]
529+
return dateFormatter.date(from: strDate)
538530
}
539531

540532
/// Return model info created from server response.

FirebaseSharedSwift/Sources/third_party/FirebaseDataEncoder/FirebaseDataEncoder.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public class FirebaseDataEncoder {
122122
case millisecondsSince1970
123123

124124
/// Encode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
125-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
126125
case iso8601
127126

128127
/// Encode the `Date` as a string formatted by the given formatter.
@@ -823,11 +822,7 @@ extension __JSONEncoder {
823822
return NSNumber(value: 1000.0 * date.timeIntervalSince1970)
824823

825824
case .iso8601:
826-
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
827825
return NSString(string: _iso8601Formatter.string(from: date))
828-
} else {
829-
fatalError("ISO8601DateFormatter is unavailable on this platform.")
830-
}
831826

832827
case .formatted(let formatter):
833828
return NSString(string: formatter.string(from: date))
@@ -1080,7 +1075,6 @@ public class FirebaseDataDecoder {
10801075
case millisecondsSince1970
10811076

10821077
/// Decode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
1083-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
10841078
case iso8601
10851079

10861080
/// Decode the `Date` as a string parsed by the given formatter.
@@ -2443,16 +2437,12 @@ extension __JSONDecoder {
24432437
return Date(timeIntervalSince1970: double / 1000.0)
24442438

24452439
case .iso8601:
2446-
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
24472440
let string = try self.unbox(value, as: String.self)!
24482441
guard let date = _iso8601Formatter.date(from: string) else {
24492442
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Expected date string to be ISO8601-formatted."))
24502443
}
24512444

24522445
return date
2453-
} else {
2454-
fatalError("ISO8601DateFormatter is unavailable on this platform.")
2455-
}
24562446

24572447
case .formatted(let formatter):
24582448
let string = try self.unbox(value, as: String.self)!
@@ -2621,7 +2611,6 @@ fileprivate struct _JSONKey : CodingKey {
26212611
//===----------------------------------------------------------------------===//
26222612

26232613
// NOTE: This value is implicitly lazy and _must_ be lazy. We're compiled against the latest SDK (w/ ISO8601DateFormatter), but linked against whichever Foundation the user has. ISO8601DateFormatter might not exist, so we better not hit this code path on an older OS.
2624-
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
26252614
fileprivate var _iso8601Formatter: ISO8601DateFormatter = {
26262615
let formatter = ISO8601DateFormatter()
26272616
formatter.formatOptions = .withInternetDateTime

FirebaseSharedSwift/Tests/third_party/DataEncoderTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ class TestFirebaseDataEncoder: XCTestCase {
302302
}
303303

304304
func testEncodingDateISO8601() {
305-
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
306305
let formatter = ISO8601DateFormatter()
307306
formatter.formatOptions = .withInternetDateTime
308307

@@ -319,7 +318,6 @@ class TestFirebaseDataEncoder: XCTestCase {
319318
expected: expected,
320319
dateEncodingStrategy: .iso8601,
321320
dateDecodingStrategy: .iso8601)
322-
}
323321
}
324322

325323
func testEncodingDateFormatted() {

0 commit comments

Comments
 (0)