Skip to content

Commit d0119bd

Browse files
totonoobs2ninjas
authored andcommitted
Don't use NSURLCache API not available in Catalyst (#1469)
* Remove bundle ID prefix for mac catalyst * Use constant for prefix * Use #if __MAC_OS_X_VERSION_MIN_REQUIRED to guard against old version * Use macOS 10.15 marcro * Just don't use old API for maccatalyst * Use @available correctly * Make macOS tests pass in Xcode 11
1 parent 1347567 commit d0119bd

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Parse/Configurations/Parse-macOS.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ INFOPLIST_FILE = $(PROJECT_DIR)/Parse/Resources/Parse-OSX.Info.plist
1818
// TODO: (nlutsenko) Cleanup source code so we can safely ignore local variable shadow warnings.
1919
GCC_WARN_SHADOW = NO
2020

21+
CONFIGURATION_BUILD_DIR=$(BUILD_DIR)/$(CONFIGURATION)
2122
FRAMEWORK_SEARCH_PATHS = $(inherited) $(SRCROOT)/../Carthage/Build/Mac

Parse/Parse/PFInstallation.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
#import "PFObjectState_Private.h"
3232
#import "PFObjectConstants.h"
3333

34+
// The prefix removed from the CFBundleIdentifier sent with the installation
35+
// for macOS Catalyst apps for installations;
36+
static const NSString * kMacCatalystBundleIdPrefix = @"maccatalyst.";
37+
38+
3439
@implementation PFInstallation (Private)
3540

3641
static NSSet *protectedKeys;
@@ -293,6 +298,22 @@ - (void)_updateVersionInfoFromDevice {
293298
NSString *appName = appInfo[(__bridge NSString *)kCFBundleNameKey];
294299
NSString *appVersion = appInfo[(__bridge NSString *)kCFBundleVersionKey];
295300
NSString *appIdentifier = appInfo[(__bridge NSString *)kCFBundleIdentifierKey];
301+
302+
#ifdef TARGET_OS_MACCATALYST
303+
// If using an Xcode new enough to know about Mac Catalyst:
304+
// Mac Catalyst Apps use a prefix to the bundle ID. This should not be transmitted
305+
// to the parse backend. Catalyst apps should look like iOS apps otherwise
306+
// push and other services don't work properly.
307+
if (@available(macCatalyst 13.0, *)) {
308+
if (appIdentifier) {
309+
NSRange macCatalystPrefix = [appIdentifier rangeOfString:(NSString *)kMacCatalystBundleIdPrefix];
310+
if (macCatalystPrefix.location == 0) {
311+
appIdentifier = [appIdentifier stringByReplacingCharactersInRange:macCatalystPrefix
312+
withString:@""];
313+
}
314+
}
315+
}
316+
#endif
296317
// It's possible that the app was created without an info.plist and we just
297318
// cannot get the data we need.
298319
// Note: it's important to make the possibly nil string the message receptor for

Parse/Tests/Unit/PinningObjectStoreTests.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ @implementation PinningObjectStoreTests
3636
#pragma mark - Tests
3737
///--------------------------------------
3838

39+
- (void)setUp
40+
{
41+
[PFPin registerSubclass];
42+
43+
[super setUp];
44+
}
45+
3946
- (void)testConstructors {
4047
id dataSource = [self mockedDataSource];
4148

0 commit comments

Comments
 (0)