Skip to content

Commit d1c5102

Browse files
authored
Added pragmas to silence availability warnings. (GH #733, #735)
1 parent 275f5f0 commit d1c5102

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
lines changed

Branch-SDK/Branch-SDK/BNCContentDiscoveryManager.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,21 +544,33 @@ - (void)indexUsingNSUserActivity:(NSDictionary *)params {
544544
// if no view controller, don't index. Current use case: iMessage extensions
545545
return;
546546
}
547+
#pragma clang diagnostic push
548+
#pragma clang diagnostic ignored "-Wpartial-availability"
549+
547550
NSString *uniqueIdentifier = [NSString stringWithFormat:@"io.branch.%@", [[NSBundle mainBundle] bundleIdentifier]];
551+
548552
// Can't create any weak references here to the userActivity, otherwise it will not index.
549553
activeViewController.userActivity = [[NSUserActivity alloc] initWithActivityType:uniqueIdentifier];
550554
activeViewController.userActivity.delegate = self;
551555
activeViewController.userActivity.title = params[@"title"];
552556
activeViewController.userActivity.webpageURL = [NSURL URLWithString:params[@"url"]];
553557
activeViewController.userActivity.eligibleForSearch = YES;
554558
activeViewController.userActivity.eligibleForPublicIndexing = [params[@"publiclyIndexable"] boolValue];
555-
activeViewController.userActivity.userInfo = self.userInfo; // This alone doesn't pass userInfo through
556-
activeViewController.userActivity.requiredUserInfoKeys = [NSSet setWithArray:self.userInfo.allKeys]; // This along with the delegate method userActivityWillSave, however, seem to force the userInfo to come through.
559+
560+
// This alone doesn't pass userInfo through
561+
activeViewController.userActivity.userInfo = self.userInfo;
562+
563+
// This along with the delegate method userActivityWillSave, however, seem to force the userInfo to come through.
564+
activeViewController.userActivity.requiredUserInfoKeys = [NSSet setWithArray:self.userInfo.allKeys];
565+
557566
activeViewController.userActivity.keywords = params[@"keywords"];
558567
SEL setContentAttributeSetSelector = NSSelectorFromString(@"setContentAttributeSet:");
559-
((void (*)(id, SEL, id))[activeViewController.userActivity methodForSelector:setContentAttributeSetSelector])(activeViewController.userActivity, setContentAttributeSetSelector, params[@"attributeSet"]);
568+
((void (*)(id, SEL, id))[activeViewController.userActivity methodForSelector:setContentAttributeSetSelector])
569+
(activeViewController.userActivity, setContentAttributeSetSelector, params[@"attributeSet"]);
560570

561571
[activeViewController.userActivity becomeCurrent];
572+
573+
#pragma clang diagnostic pop
562574
}
563575

564576
@end

Branch-SDK/Branch-SDK/BNCDeviceInfo.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,12 @@ + (NSString*) bnc_country {
215215

216216
// Should work on iOS 10
217217
NSLocale *currentLocale = [NSLocale currentLocale];
218+
#pragma clang diagnostic push
219+
#pragma clang diagnostic ignored "-Wpartial-availability"
218220
if ([currentLocale respondsToSelector:@selector(countryCode)]) {
219221
country = [currentLocale countryCode];
220222
}
223+
#pragma clang diagnostic pop
221224
returnIfValidCountry();
222225

223226
// Should work on iOS 9
@@ -252,10 +255,13 @@ + (NSString*) bnc_language {
252255
} \
253256

254257
// Should work on iOS 10
258+
#pragma clang diagnostic push
259+
#pragma clang diagnostic ignored "-Wpartial-availability"
255260
NSLocale *currentLocale = [NSLocale currentLocale];
256261
if ([currentLocale respondsToSelector:@selector(languageCode)]) {
257262
language = [currentLocale languageCode];
258263
}
264+
#pragma clang diagnostic pop
259265
returnIfValidLanguage();
260266

261267
// Should work on iOS 9

Branch-SDK/Branch-SDK/BNCStrongMatchHelper.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ + (NSURL *)getUrlForCookieBasedMatchingWithBranchKey:(NSString *)branchKey
4444

4545

4646
#else // ------------------------------------------------------------------------------ iOS >= 9.0
47+
#pragma clang diagnostic push
48+
#pragma clang diagnostic ignored "-Wpartial-availability"
49+
4750
@import SafariServices;
4851

4952

@@ -367,4 +370,5 @@ - (void)safariViewController:(SFSafariViewController *)controller
367370

368371
@end
369372

373+
#pragma clang diagnostic pop
370374
#endif // ------------------------------------------------------------------------------ iOS >= 9.0

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,14 @@ - (BOOL)application:(UIApplication *)application
672672

673673
NSString *source = nil;
674674
NSString *annotation = nil;
675+
#pragma clang diagnostic push
676+
#pragma clang diagnostic ignored "-Wpartial-availability"
675677
if (UIApplicationOpenURLOptionsSourceApplicationKey &&
676678
UIApplicationOpenURLOptionsAnnotationKey) {
677679
source = options[UIApplicationOpenURLOptionsSourceApplicationKey];
678680
annotation = options[UIApplicationOpenURLOptionsAnnotationKey];
679681
}
682+
#pragma clang diagnostic pop
680683
return [self application:application openURL:url sourceApplication:source annotation:annotation];
681684
}
682685

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@
12081208
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
12091209
CLANG_WARN_STRICT_PROTOTYPES = YES;
12101210
CLANG_WARN_SUSPICIOUS_MOVE = YES;
1211+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
12111212
CLANG_WARN_UNREACHABLE_CODE = YES;
12121213
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
12131214
CODE_SIGN_IDENTITY = "iPhone Developer";
@@ -1259,6 +1260,7 @@
12591260
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
12601261
CLANG_WARN_STRICT_PROTOTYPES = YES;
12611262
CLANG_WARN_SUSPICIOUS_MOVE = YES;
1263+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
12621264
CLANG_WARN_UNREACHABLE_CODE = YES;
12631265
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
12641266
CODE_SIGN_IDENTITY = "iPhone Developer";
@@ -1292,6 +1294,7 @@
12921294
GCC_PRECOMPILE_PREFIX_HEADER = YES;
12931295
GCC_PREFIX_HEADER = "Branch-TestBed/Branch-TestBed-Prefix.pch";
12941296
INFOPLIST_FILE = "Branch-TestBed/Branch-TestBed-Info.plist";
1297+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
12951298
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed";
12961299
PRODUCT_NAME = "$(TARGET_NAME)";
12971300
PROVISIONING_PROFILE = "";
@@ -1312,6 +1315,7 @@
13121315
GCC_PRECOMPILE_PREFIX_HEADER = YES;
13131316
GCC_PREFIX_HEADER = "Branch-TestBed/Branch-TestBed-Prefix.pch";
13141317
INFOPLIST_FILE = "Branch-TestBed/Branch-TestBed-Info.plist";
1318+
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
13151319
PRODUCT_BUNDLE_IDENTIFIER = "io.branch.sdk.Branch-TestBed";
13161320
PRODUCT_NAME = "$(TARGET_NAME)";
13171321
PROVISIONING_PROFILE = "";

Branch-TestBed/Branch-TestBed/ViewController.m

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,7 @@ - (IBAction) sendCommerceEvent:(id)sender {
363363
NSString *message =
364364
[NSString stringWithFormat:@"Commerce completion called.\nError: %@\n%@", error, response];
365365
NSLog(@"%@", message);
366-
[[[UIAlertView alloc]
367-
initWithTitle:@"Commerce Event"
368-
message:message
369-
delegate:nil
370-
cancelButtonTitle:@"OK"
371-
otherButtonTitles:nil]
372-
show];
366+
[self showAlert:@"Commerce Event" withDescription:message];
373367
}];
374368
}
375369

@@ -453,13 +447,16 @@ - (void)showAlert: (NSString *)title withDescription:(NSString *) message {
453447

454448
if ([UIDevice currentDevice].systemVersion.floatValue < 8.0) {
455449

450+
#pragma clang diagnostic push
451+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
456452
UIAlertView *alert = [[UIAlertView alloc]
457453
initWithTitle:title
458454
message:message
459455
delegate:nil
460456
cancelButtonTitle:@"OK"
461457
otherButtonTitles:nil];
462458
[alert show];
459+
#pragma clang diagnostic pop
463460

464461
} else {
465462

0 commit comments

Comments
 (0)