Skip to content

Commit

Permalink
[v10] Minimum platform updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 committed Jun 6, 2024
1 parent 4df4854 commit 61dc368
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 105 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions GoogleDataTransport.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}/"'
Expand Down
100 changes: 25 additions & 75 deletions GoogleDataTransport/GDTCORLibrary/GDTCORPlatform.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,13 @@ GDTCORNetworkMobileSubtype GDTCORNetworkMobileSubTypeMessage(void) {
if (networkCurrentRadioAccessTechnologyDict.count) {
networkCurrentRadioAccessTechnology = networkCurrentRadioAccessTechnologyDict.allValues[0];
}
#else // TARGET_OS_MACCATALYST
if (@available(iOS 12.0, *)) {
NSDictionary<NSString *, NSString *> *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<NSString *, NSString *> *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) {
Expand Down Expand Up @@ -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;
Expand All @@ -261,26 +228,9 @@ GDTCORNetworkMobileSubtype GDTCORNetworkMobileSubTypeMessage(void) {
id<NSSecureCoding> _Nullable GDTCORDecodeArchive(Class archiveClass,
NSData *_Nonnull archiveData,
NSError **_Nonnull error) {
id<NSSecureCoding> 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) {
Expand Down
1 change: 0 additions & 1 deletion GoogleDataTransport/GDTTestApp/EventCleanupPerfTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
24 changes: 8 additions & 16 deletions GoogleDataTransport/GDTTestApp/viewcontroller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
11 changes: 4 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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",
Expand All @@ -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.
Expand Down

0 comments on commit 61dc368

Please sign in to comment.