From d834b6c58d0aae77802399330e751fc418b66f3d Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 21 Oct 2020 16:20:12 -0700 Subject: [PATCH] fix: macOS 10.11/10.13 compile warning fix (#309) * fixed warnings by adding macOS to @available check and -Wunguarded-availability directive --- Sources/Amplitude/Amplitude.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/Amplitude/Amplitude.m b/Sources/Amplitude/Amplitude.m index b622afa0..60f52ac1 100644 --- a/Sources/Amplitude/Amplitude.m +++ b/Sources/Amplitude/Amplitude.m @@ -1686,11 +1686,12 @@ - (id)unarchive:(NSString*)path { } - (id)unarchive:(NSData *)data error:(NSError **)error { - if (@available(iOS 12, tvOS 11.0, *)) { + if (@available(iOS 12, tvOS 11.0, macOS 10.13, *)) { return [NSKeyedUnarchiver unarchivedObjectOfClass:[NSDictionary class] fromData:data error:error]; } else { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" +#pragma clang diagnostic ignored "-Wunguarded-availability" // Safe to use this flag since API only used with macOS > 10.11 from (id)unarchive:(NSString*)path // Even with the availability check above, Xcode would still emit a deprecation warning here. // Since there's no way that it could be reached on iOS's >= 12.0 or tvOS's >= 11.0 // (where `[NSKeyedUnarchiver unarchiveTopLevelObjectWithData:error:]` was deprecated), @@ -1701,7 +1702,7 @@ - (id)unarchive:(NSData *)data error:(NSError **)error { } - (BOOL)archive:(id) obj toFile:(NSString*)path { - if (@available(tvOS 11.0, iOS 12, *)) { + if (@available(tvOS 11.0, iOS 12, macOS 10.13, *)) { NSError *archiveError = nil; NSData *data = [NSKeyedArchiver archivedDataWithRootObject:obj requiringSecureCoding:NO error:&archiveError]; if (archiveError != nil) {