From a66c3e563500747e65c532ff208d2a42b0b85367 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Tue, 5 Nov 2019 16:39:39 +0100 Subject: [PATCH 01/14] Don't use api not available in catalyst --- .../URLSession/PFURLSessionCommandRunner.m | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index 9ce009216..ecf51ac93 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -275,10 +275,25 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin directoryURL:nil]; #else // Completely disable caching of responses for security reasons. - configuration.URLCache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity - diskCapacity:0 - diskPath:nil]; + NSURLCache *cache; + + if (@available(iOS 13.0, *) + || @available(tvOS 13.0, *) + || @available(macOS 10.15, *) + || @available(watchOS 6.0, *) + || @available(macCatalyst 13.0, *)) { + cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity + diskCapacity:0 + directoryURL:nil]; + } else { +#if !TARGET_OS_MACCATALYST + cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity + diskCapacity:0 + directoryPath:nil]; #endif + } + + configuration.URLCache = cache; NSBundle *bundle = [NSBundle mainBundle]; NSDictionary *headers = [PFCommandURLRequestConstructor defaultURLRequestHeadersForApplicationId:applicationId From 4b65cc5752170ae61f2146c06129188e76bcaa03 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Sat, 9 Nov 2019 16:28:38 +0100 Subject: [PATCH 02/14] Fix deprecation for newer stuff --- .../URLSession/PFURLSessionCommandRunner.m | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index ecf51ac93..381826daa 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -277,22 +277,18 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin // Completely disable caching of responses for security reasons. NSURLCache *cache; - if (@available(iOS 13.0, *) - || @available(tvOS 13.0, *) - || @available(macOS 10.15, *) - || @available(watchOS 6.0, *) - || @available(macCatalyst 13.0, *)) { +#ifdef __IPHONE_13_0 || __TVOS_13 || __WATCHOS_6_0 || __MAC_10_15 cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity diskCapacity:0 directoryURL:nil]; - } else { -#if !TARGET_OS_MACCATALYST + +#else cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity diskCapacity:0 directoryPath:nil]; -#endif - } + +#endif configuration.URLCache = cache; NSBundle *bundle = [NSBundle mainBundle]; From 247379f8942278c5e977c72b3ff257c8d7c926a9 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Tue, 12 Nov 2019 13:30:45 +0100 Subject: [PATCH 03/14] Remove bundle ID prefix for mac catalyst --- Parse/Parse/PFInstallation.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Parse/Parse/PFInstallation.m b/Parse/Parse/PFInstallation.m index 25aeb96c0..fcbd8dd19 100644 --- a/Parse/Parse/PFInstallation.m +++ b/Parse/Parse/PFInstallation.m @@ -293,6 +293,17 @@ - (void)_updateVersionInfoFromDevice { NSString *appName = appInfo[(__bridge NSString *)kCFBundleNameKey]; NSString *appVersion = appInfo[(__bridge NSString *)kCFBundleVersionKey]; NSString *appIdentifier = appInfo[(__bridge NSString *)kCFBundleIdentifierKey]; + + // Mac Catalyst Apps use a prefix to the bundle ID. This should not be transmitted + // to the parse backend. Catalyst apps should look like iOS apps otherwise + // push and other services don't work properly. + if (@available(macCatalyst 13.0, *) && appIdentifier) { + NSRange macCatalystPrefix = [appIdentifier rangeOfString:@"maccatalyst."]; + if (macCatalystPrefix.location == 0) { + appIdentifier = [appIdentifier stringByReplacingCharactersInRange:macCatalystPrefix + withString:@""]; + } + } // It's possible that the app was created without an info.plist and we just // cannot get the data we need. // Note: it's important to make the possibly nil string the message receptor for From 03eb87253ccdae6e31687f04fce4aa60c715917f Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Tue, 12 Nov 2019 13:36:14 +0100 Subject: [PATCH 04/14] Use constant for prefix --- Parse/Parse/PFInstallation.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Parse/Parse/PFInstallation.m b/Parse/Parse/PFInstallation.m index fcbd8dd19..c7488a04a 100644 --- a/Parse/Parse/PFInstallation.m +++ b/Parse/Parse/PFInstallation.m @@ -31,6 +31,11 @@ #import "PFObjectState_Private.h" #import "PFObjectConstants.h" +// The prefix removed from the CFBundleIdentifier sent with the installation +// for macOS Catalyst apps for installations; +const NSString * kMacCatalystBundleIdPrefix = @"maccatalyst."; + + @implementation PFInstallation (Private) static NSSet *protectedKeys; @@ -298,7 +303,7 @@ - (void)_updateVersionInfoFromDevice { // to the parse backend. Catalyst apps should look like iOS apps otherwise // push and other services don't work properly. if (@available(macCatalyst 13.0, *) && appIdentifier) { - NSRange macCatalystPrefix = [appIdentifier rangeOfString:@"maccatalyst."]; + NSRange macCatalystPrefix = [appIdentifier rangeOfString:(NSString *)kMacCatalystBundleIdPrefix]; if (macCatalystPrefix.location == 0) { appIdentifier = [appIdentifier stringByReplacingCharactersInRange:macCatalystPrefix withString:@""]; From 7a43149815e06da93f5929c00f2519e4c309150d Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Tue, 12 Nov 2019 13:54:33 +0100 Subject: [PATCH 05/14] Use #if __MAC_OS_X_VERSION_MIN_REQUIRED to guard against old version --- .../URLSession/PFURLSessionCommandRunner.m | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index 381826daa..3c1f34259 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -277,17 +277,14 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin // Completely disable caching of responses for security reasons. NSURLCache *cache; -#ifdef __IPHONE_13_0 || __TVOS_13 || __WATCHOS_6_0 || __MAC_10_15 - cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity - diskCapacity:0 - directoryURL:nil]; - +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity + diskCapacity:0 + directoryPath:nil]; #else - cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity - diskCapacity:0 - directoryPath:nil]; - - + cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity + diskCapacity:0 + directoryURL:nil]; #endif configuration.URLCache = cache; From 9f7c5f21482dddf70e6dfa7fa7e6775ce698e363 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Tue, 12 Nov 2019 16:33:05 +0100 Subject: [PATCH 06/14] Use macOS 10.15 marcro --- .../CommandRunner/URLSession/PFURLSessionCommandRunner.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index 3c1f34259..7651fb3a5 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -277,7 +277,7 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin // Completely disable caching of responses for security reasons. NSURLCache *cache; -#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 +#ifndef __MAC_10_15 cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity diskCapacity:0 directoryPath:nil]; From b93309f8c8bab9243abd4433fc4f850b97728e67 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Wed, 13 Nov 2019 10:20:35 +0100 Subject: [PATCH 07/14] Just don't use old API for maccatalyst --- .../CommandRunner/URLSession/PFURLSessionCommandRunner.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index 7651fb3a5..7c92ba536 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -277,14 +277,14 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin // Completely disable caching of responses for security reasons. NSURLCache *cache; -#ifndef __MAC_10_15 +#if TARGET_OS_MACCATALYST cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity diskCapacity:0 - directoryPath:nil]; + directoryURL:nil]; #else cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity diskCapacity:0 - directoryURL:nil]; + directoryPath:nil]; #endif configuration.URLCache = cache; From 513c437b762a0e991806225348db9160ab53b020 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Wed, 13 Nov 2019 10:24:11 +0100 Subject: [PATCH 08/14] Fix old API --- .../CommandRunner/URLSession/PFURLSessionCommandRunner.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index 7c92ba536..fcb0c13c4 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -284,7 +284,7 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin #else cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity diskCapacity:0 - directoryPath:nil]; + diskPath:nil]; #endif configuration.URLCache = cache; From 76d2d7075f8ef393887b95bdf76b0b6529549431 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Wed, 13 Nov 2019 17:40:03 +0100 Subject: [PATCH 09/14] Fix build on older SDKs --- Parse/Parse/PFInstallation.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Parse/Parse/PFInstallation.m b/Parse/Parse/PFInstallation.m index c7488a04a..e8373c376 100644 --- a/Parse/Parse/PFInstallation.m +++ b/Parse/Parse/PFInstallation.m @@ -299,6 +299,8 @@ - (void)_updateVersionInfoFromDevice { NSString *appVersion = appInfo[(__bridge NSString *)kCFBundleVersionKey]; NSString *appIdentifier = appInfo[(__bridge NSString *)kCFBundleIdentifierKey]; +#ifdef TARGET_OS_MACCATALYST + // If using an Xcode new enough to know about Mac Catalyst: // Mac Catalyst Apps use a prefix to the bundle ID. This should not be transmitted // to the parse backend. Catalyst apps should look like iOS apps otherwise // push and other services don't work properly. @@ -309,6 +311,7 @@ - (void)_updateVersionInfoFromDevice { withString:@""]; } } +#endif // It's possible that the app was created without an info.plist and we just // cannot get the data we need. // Note: it's important to make the possibly nil string the message receptor for From 2bd7a46bea086819e0db3c62951a8cd756553039 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Wed, 13 Nov 2019 18:02:29 +0100 Subject: [PATCH 10/14] Use @available correctly --- Parse/Parse/PFInstallation.m | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Parse/Parse/PFInstallation.m b/Parse/Parse/PFInstallation.m index e8373c376..cd814f1b5 100644 --- a/Parse/Parse/PFInstallation.m +++ b/Parse/Parse/PFInstallation.m @@ -300,15 +300,17 @@ - (void)_updateVersionInfoFromDevice { NSString *appIdentifier = appInfo[(__bridge NSString *)kCFBundleIdentifierKey]; #ifdef TARGET_OS_MACCATALYST - // If using an Xcode new enough to know about Mac Catalyst: - // Mac Catalyst Apps use a prefix to the bundle ID. This should not be transmitted - // to the parse backend. Catalyst apps should look like iOS apps otherwise - // push and other services don't work properly. - if (@available(macCatalyst 13.0, *) && appIdentifier) { - NSRange macCatalystPrefix = [appIdentifier rangeOfString:(NSString *)kMacCatalystBundleIdPrefix]; - if (macCatalystPrefix.location == 0) { - appIdentifier = [appIdentifier stringByReplacingCharactersInRange:macCatalystPrefix - withString:@""]; + // If using an Xcode new enough to know about Mac Catalyst: + // Mac Catalyst Apps use a prefix to the bundle ID. This should not be transmitted + // to the parse backend. Catalyst apps should look like iOS apps otherwise + // push and other services don't work properly. + if (@available(macCatalyst 13.0, *)) { + if (appIdentifier) { + NSRange macCatalystPrefix = [appIdentifier rangeOfString:(NSString *)kMacCatalystBundleIdPrefix]; + if (macCatalystPrefix.location == 0) { + appIdentifier = [appIdentifier stringByReplacingCharactersInRange:macCatalystPrefix + withString:@""]; + } } } #endif From 55057849703d1b59e08201afa5ef77ae8cdf919f Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Wed, 13 Nov 2019 22:32:55 +0100 Subject: [PATCH 11/14] Fix warning by declaring non-extern const as static. --- Parse/Parse/PFInstallation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Parse/Parse/PFInstallation.m b/Parse/Parse/PFInstallation.m index cd814f1b5..445f91325 100644 --- a/Parse/Parse/PFInstallation.m +++ b/Parse/Parse/PFInstallation.m @@ -33,7 +33,7 @@ // The prefix removed from the CFBundleIdentifier sent with the installation // for macOS Catalyst apps for installations; -const NSString * kMacCatalystBundleIdPrefix = @"maccatalyst."; +static const NSString * kMacCatalystBundleIdPrefix = @"maccatalyst."; @implementation PFInstallation (Private) From 200fb1d2eebbb3f00011300c10982aa9f7667327 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Wed, 13 Nov 2019 22:58:59 +0100 Subject: [PATCH 12/14] Make macOS tests pass in Xcode 11 --- Parse/Configurations/Parse-macOS.xcconfig | 1 + Parse/Tests/Unit/PinningObjectStoreTests.m | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Parse/Configurations/Parse-macOS.xcconfig b/Parse/Configurations/Parse-macOS.xcconfig index 893d35113..1f11e5dd1 100644 --- a/Parse/Configurations/Parse-macOS.xcconfig +++ b/Parse/Configurations/Parse-macOS.xcconfig @@ -18,4 +18,5 @@ INFOPLIST_FILE = $(PROJECT_DIR)/Parse/Resources/Parse-OSX.Info.plist // TODO: (nlutsenko) Cleanup source code so we can safely ignore local variable shadow warnings. GCC_WARN_SHADOW = NO +CONFIGURATION_BUILD_DIR=$(BUILD_DIR)/$(CONFIGURATION) FRAMEWORK_SEARCH_PATHS = $(inherited) $(SRCROOT)/../Carthage/Build/Mac diff --git a/Parse/Tests/Unit/PinningObjectStoreTests.m b/Parse/Tests/Unit/PinningObjectStoreTests.m index 064068b7b..524319adb 100644 --- a/Parse/Tests/Unit/PinningObjectStoreTests.m +++ b/Parse/Tests/Unit/PinningObjectStoreTests.m @@ -36,6 +36,13 @@ @implementation PinningObjectStoreTests #pragma mark - Tests ///-------------------------------------- +- (void)setUp +{ + [PFPin registerSubclass]; + + [super setUp]; +} + - (void)testConstructors { id dataSource = [self mockedDataSource]; From 2a3c6f7e2489e71c06680a4693c7d76d7bce37b3 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Fri, 6 Dec 2019 12:30:17 +0100 Subject: [PATCH 13/14] re-up stuff to upstream master --- .../URLSession/PFURLSessionCommandRunner.m | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index fcb0c13c4..5d9026c98 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -275,18 +275,10 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin directoryURL:nil]; #else // Completely disable caching of responses for security reasons. - NSURLCache *cache; - -#if TARGET_OS_MACCATALYST - cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity - diskCapacity:0 - directoryURL:nil]; -#else - cache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity - diskCapacity:0 - diskPath:nil]; + configuration.URLCache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity + diskCapacity:0 + diskPath:nil]; #endif - configuration.URLCache = cache; NSBundle *bundle = [NSBundle mainBundle]; NSDictionary *headers = [PFCommandURLRequestConstructor defaultURLRequestHeadersForApplicationId:applicationId From a54716fcb455a910c2bb1d6738d00fc4f33a6926 Mon Sep 17 00:00:00 2001 From: Thomas Kollbach Date: Fri, 6 Dec 2019 12:31:14 +0100 Subject: [PATCH 14/14] remove ws diff --- .../CommandRunner/URLSession/PFURLSessionCommandRunner.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m index 5d9026c98..9ce009216 100644 --- a/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m +++ b/Parse/Parse/Internal/Commands/CommandRunner/URLSession/PFURLSessionCommandRunner.m @@ -276,8 +276,8 @@ + (NSURLSessionConfiguration *)_urlSessionConfigurationForApplicationId:(NSStrin #else // Completely disable caching of responses for security reasons. configuration.URLCache = [[NSURLCache alloc] initWithMemoryCapacity:[NSURLCache sharedURLCache].memoryCapacity - diskCapacity:0 - diskPath:nil]; + diskCapacity:0 + diskPath:nil]; #endif NSBundle *bundle = [NSBundle mainBundle];