Skip to content

Commit

Permalink
fix: macOS 10.11/10.13 compile warning fix (#309)
Browse files Browse the repository at this point in the history
* fixed warnings by adding macOS to @available check and -Wunguarded-availability directive
  • Loading branch information
jooohhn authored Oct 21, 2020
1 parent 18710c5 commit d834b6c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/Amplitude/Amplitude.m
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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) {
Expand Down

0 comments on commit d834b6c

Please sign in to comment.