From 61dc368b81b4fd46c175ecb9e83bba55fbd4e726 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 6 Jun 2024 14:06:26 -0700 Subject: [PATCH] [v10] Minimum platform updates --- CHANGELOG.md | 9 +- GoogleDataTransport.podspec | 10 +- .../GDTCORLibrary/GDTCORPlatform.m | 100 +++++------------- .../GDTTestApp/EventCleanupPerfTest.swift | 1 - .../GDTTestApp/viewcontroller.swift | 24 ++--- Package.swift | 11 +- 6 files changed, 50 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b75224..3f99690 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ -# Unreleased +# v10.0.0 - Fix null pointer warning from profiler. (#124) +- [changed] **Breaking change**: Platform Minimum supported version updates: + - | Platform | GoogleUtilities 8.0| + | ------------- | ------------- | + | iOS | **12.0** | + | tvOS | **13.0** | + | macOS | **10.15** | + | watchOS | **7.0** | # v9.4.1 (CocoaPods Only) - The v9.4.0 podspec did not include the intended dependency range for nanopb diff --git a/GoogleDataTransport.podspec b/GoogleDataTransport.podspec index c0853bf..6d8fb7c 100644 --- a/GoogleDataTransport.podspec +++ b/GoogleDataTransport.podspec @@ -15,10 +15,10 @@ Shared library for iOS SDK data transport needs. :tag => 'CocoaPods-' + s.version.to_s } - ios_deployment_target = '9.0' - osx_deployment_target = '10.12' - tvos_deployment_target = '10.0' - watchos_deployment_target = '6.0' + ios_deployment_target = '12.0' + osx_deployment_target = '10.15' + tvos_deployment_target = '13.0' + watchos_deployment_target = '7.0' s.ios.deployment_target = ios_deployment_target s.osx.deployment_target = osx_deployment_target @@ -41,7 +41,7 @@ Shared library for iOS SDK data transport needs. s.dependency 'GoogleUtilities/Environment', '~> 8.0' s.dependency 'nanopb', '>= 2.30908.0', '< 2.30911.0' - s.dependency 'PromisesObjC', '>= 1.2', '< 3.0' + s.dependency 'PromisesObjC', '~> 2.4' header_search_paths = { 'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}/"' diff --git a/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m b/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m index 1d89528..584f3dd 100644 --- a/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m +++ b/GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m @@ -129,19 +129,13 @@ GDTCORNetworkMobileSubtype GDTCORNetworkMobileSubTypeMessage(void) { if (networkCurrentRadioAccessTechnologyDict.count) { networkCurrentRadioAccessTechnology = networkCurrentRadioAccessTechnologyDict.allValues[0]; } -#else // TARGET_OS_MACCATALYST - if (@available(iOS 12.0, *)) { - NSDictionary *networkCurrentRadioAccessTechnologyDict = - networkInfo.serviceCurrentRadioAccessTechnology; - if (networkCurrentRadioAccessTechnologyDict.count) { - // In iOS 12, multiple radio technologies can be captured. We prefer not particular radio - // tech to another, so we'll just return the first value in the dictionary. - networkCurrentRadioAccessTechnology = networkCurrentRadioAccessTechnologyDict.allValues[0]; - } - } else { -#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < 120000 - networkCurrentRadioAccessTechnology = networkInfo.currentRadioAccessTechnology; -#endif // TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED < 120000 +#else // TARGET_OS_MACCATALYST + NSDictionary *networkCurrentRadioAccessTechnologyDict = + networkInfo.serviceCurrentRadioAccessTechnology; + if (networkCurrentRadioAccessTechnologyDict.count) { + // In iOS 12, multiple radio technologies can be captured. We prefer not particular radio + // tech to another, so we'll just return the first value in the dictionary. + networkCurrentRadioAccessTechnology = networkCurrentRadioAccessTechnologyDict.allValues[0]; } #endif // TARGET_OS_MACCATALYST if (networkCurrentRadioAccessTechnology) { @@ -197,50 +191,23 @@ GDTCORNetworkMobileSubtype GDTCORNetworkMobileSubTypeMessage(void) { } } NSData *resultData; - if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4, *)) { - resultData = [NSKeyedArchiver archivedDataWithRootObject:obj - requiringSecureCoding:YES - error:error]; - if (resultData == nil || (error != NULL && *error != nil)) { - GDTCORLogDebug(@"Encoding an object failed: %@", *error); - return nil; - } - if (filePath.length > 0) { - result = [resultData writeToFile:filePath options:NSDataWritingAtomic error:error]; - if (result == NO || (error != NULL && *error != nil)) { - if (error != NULL && *error != nil) { - GDTCORLogDebug(@"Attempt to write archive failed: path:%@ error:%@", filePath, *error); - } else { - GDTCORLogDebug(@"Attempt to write archive failed: path:%@", filePath); - } + resultData = [NSKeyedArchiver archivedDataWithRootObject:obj + requiringSecureCoding:YES + error:error]; + if (resultData == nil || (error != NULL && *error != nil)) { + GDTCORLogDebug(@"Encoding an object failed: %@", *error); + return nil; + } + if (filePath.length > 0) { + result = [resultData writeToFile:filePath options:NSDataWritingAtomic error:error]; + if (result == NO || (error != NULL && *error != nil)) { + if (error != NULL && *error != nil) { + GDTCORLogDebug(@"Attempt to write archive failed: path:%@ error:%@", filePath, *error); } else { - GDTCORLogDebug(@"Writing archive succeeded: %@", filePath); + GDTCORLogDebug(@"Attempt to write archive failed: path:%@", filePath); } - } - } else { - @try { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - resultData = [NSKeyedArchiver archivedDataWithRootObject:obj]; -#pragma clang diagnostic pop - if (filePath.length > 0) { - result = [resultData writeToFile:filePath options:NSDataWritingAtomic error:error]; - if (result == NO || *error) { - GDTCORLogDebug(@"Attempt to write archive failed: URL:%@ error:%@", filePath, *error); - } else { - GDTCORLogDebug(@"Writing archive succeeded: %@", filePath); - } - } - } @catch (NSException *exception) { - NSString *errorString = - [NSString stringWithFormat:@"An exception was thrown during encoding: %@", exception]; - *error = [NSError errorWithDomain:NSCocoaErrorDomain - code:-1 - userInfo:@{NSLocalizedFailureReasonErrorKey : errorString}]; - } - if (filePath.length > 0) { - GDTCORLogDebug(@"Attempt to write archive. successful:%@ URL:%@ error:%@", - result ? @"YES" : @"NO", filePath, *error); + } else { + GDTCORLogDebug(@"Writing archive succeeded: %@", filePath); } } return resultData; @@ -261,26 +228,9 @@ GDTCORNetworkMobileSubtype GDTCORNetworkMobileSubTypeMessage(void) { id _Nullable GDTCORDecodeArchive(Class archiveClass, NSData *_Nonnull archiveData, NSError **_Nonnull error) { - id unarchivedObject = nil; - if (@available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4, *)) { - unarchivedObject = [NSKeyedUnarchiver unarchivedObjectOfClass:archiveClass - fromData:archiveData - error:error]; - } else { - @try { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - unarchivedObject = [NSKeyedUnarchiver unarchiveObjectWithData:archiveData]; -#pragma clang diagnostic pop - } @catch (NSException *exception) { - NSString *errorString = - [NSString stringWithFormat:@"An exception was thrown during encoding: %@", exception]; - *error = [NSError errorWithDomain:NSCocoaErrorDomain - code:-1 - userInfo:@{NSLocalizedFailureReasonErrorKey : errorString}]; - } - } - return unarchivedObject; + return [NSKeyedUnarchiver unarchivedObjectOfClass:archiveClass + fromData:archiveData + error:error]; } BOOL GDTCORWriteDataToFile(NSData *data, NSString *filePath, NSError *_Nullable *outError) { diff --git a/GoogleDataTransport/GDTTestApp/EventCleanupPerfTest.swift b/GoogleDataTransport/GDTTestApp/EventCleanupPerfTest.swift index df141ed..d8164bf 100644 --- a/GoogleDataTransport/GDTTestApp/EventCleanupPerfTest.swift +++ b/GoogleDataTransport/GDTTestApp/EventCleanupPerfTest.swift @@ -22,7 +22,6 @@ import os.signpost /// The test actions to run under the profiler to measure performance of /// `GDTCORFlatFileStorage.checkForExpirations()` method. -@available(iOS 12.0, *) enum EventCleanupPerfTest { static let log = OSLog(subsystem: "GoogleDataTransport-TestApp", category: "EventCleanupPerfTest") diff --git a/GoogleDataTransport/GDTTestApp/viewcontroller.swift b/GoogleDataTransport/GDTTestApp/viewcontroller.swift index db184e9..18db948 100644 --- a/GoogleDataTransport/GDTTestApp/viewcontroller.swift +++ b/GoogleDataTransport/GDTTestApp/viewcontroller.swift @@ -64,28 +64,20 @@ public extension ViewController { } @IBAction func generateTestEvents(button: UIButton) { - if #available(iOS 12.0, *) { - let numberOfEvents = 10000 - set(status: "Generating \(numberOfEvents) events") + let numberOfEvents = 10000 + set(status: "Generating \(numberOfEvents) events") - EventCleanupPerfTest.generateTestEvents(count: numberOfEvents) { - self.set(status: "Generated \(numberOfEvents) events") - } - } else { - print("Performance testing set up for iOS 12.0 and later") + EventCleanupPerfTest.generateTestEvents(count: numberOfEvents) { + self.set(status: "Generated \(numberOfEvents) events") } } @IBAction func runEventCleanupPerformanceTest(button: UIButton) { - if #available(iOS 12.0, *) { - set(status: "Event Cleanup Performance Test started") - EventCleanupPerfTest.run { - DispatchQueue.main.async { - self.set(status: "Event Cleanup Performance Test finished") - } + set(status: "Event Cleanup Performance Test started") + EventCleanupPerfTest.run { + DispatchQueue.main.async { + self.set(status: "Event Cleanup Performance Test finished") } - } else { - print("Performance testing set up for iOS 12.0 and later") } } diff --git a/Package.swift b/Package.swift index 029bac5..43f45b1 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.3 +// swift-tools-version:5.9 // The swift-tools-version declares the minimum version of Swift required to build this package. // Copyright 2021 Google LLC @@ -19,7 +19,7 @@ import PackageDescription let package = Package( name: "GoogleDataTransport", - platforms: [.iOS(.v10), .macOS(.v10_12), .tvOS(.v10), .watchOS(.v6)], + platforms: [.iOS(.v12), .macOS(.v10_15), .tvOS(.v13), .watchOS(.v7)], products: [ .library( name: "GoogleDataTransport", @@ -28,20 +28,17 @@ let package = Package( ], dependencies: [ .package( - name: "nanopb", url: "https://github.com/firebase/nanopb.git", "2.30908.0" ..< "2.30911.0" ), .package( - name: "Promises", url: "https://github.com/google/promises.git", - "1.2.8" ..< "3.0.0" + "2.4.0" ..< "3.0.0" ), .package( - name: "GoogleUtilities", url: "https://github.com/google/GoogleUtilities.git", // TODO: Update to '"8.0.0" ..< "9.0.0"' when ready. - .branch("release-8.0") + branch: "release-8.0" ), ], // TODO: Restructure directory structure to simplify the excludes here.