Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing IAM on m1 catalyst #1076

Merged
merged 4 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,7 @@
INFOPLIST_FILE = UnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "-fembed-bitcode";
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.UnitTests;
Expand Down Expand Up @@ -2489,6 +2490,7 @@
INFOPLIST_FILE = UnitTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "-fembed-bitcode";
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.UnitTests;
Expand Down Expand Up @@ -2581,12 +2583,14 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = UnitTestApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 13.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
OTHER_CFLAGS = "-fembed-bitcode";
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.UnitTestApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down Expand Up @@ -2629,13 +2633,15 @@
);
INFOPLIST_FILE = UnitTestApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 13.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-fembed-bitcode";
PRODUCT_BUNDLE_IDENTIFIER = com.onesignal.example.UnitTestApp;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down
14 changes: 7 additions & 7 deletions iOS_SDK/OneSignalSDK/Source/OneSignalHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,16 @@ + (NSString*)getDeviceVariant {
let systemInfoMachine = [self getSystemInfoMachine];

// x86_64 could mean an iOS Simulator or Catalyst app on macOS
if ([systemInfoMachine isEqualToString:@"x86_64"]) {
let systemName = UIDevice.currentDevice.systemName;
if ([systemName isEqualToString:@"iOS"]) {
let model = UIDevice.currentDevice.model;
#if TARGET_OS_MACCATALYST
return @"Mac";
#elif TARGET_OS_SIMULATOR
let model = UIDevice.currentDevice.model;
if (model) {
return [@"Simulator " stringByAppendingString:model];
} else {
return @"Mac";
return @"Simulator";
}
}

#endif
return systemInfoMachine;
}

Expand Down
4 changes: 4 additions & 0 deletions iOS_SDK/OneSignalSDK/UnitTestApp/UnitTestApp.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
9 changes: 6 additions & 3 deletions iOS_SDK/OneSignalSDK/UnitTests/InAppMessagingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,16 @@ -(void)testOldUnsupportedIpadSimulator {
XCTAssertEqualObjects(sharedInstance.class, DummyOSMessagingController.class); // sharedInstance should be dummy controller
}

// This test needs to be run with Mac Catalyst as the build target
-(void)testUnsupportedCatalyst {
OneSignalHelperOverrider.mockIOSVersion = 10;
[OSMessagingController removeInstance];
[OneSignalHelperOverrider setSystemInfoMachine:@"x86_64"];
[UIDeviceOverrider setSystemName:@"Mac OS X"]; // e.g. @"Mac OS X" @"iOS"
let sharedInstance = OSMessagingController.sharedInstance;
XCTAssertEqualObjects(sharedInstance.class, DummyOSMessagingController.class); // sharedInstance should be dummy controller
#if TARGET_OS_MACCATALYST
XCTAssertEqualObjects(sharedInstance.class, DummyOSMessagingController.class); // sharedInstance should be dummy controller
#else
XCTAssertEqualObjects(sharedInstance.class, OSMessagingController.class); // sharedInstance should be the true controller
#endif
}

-(void)testRealIphone {
Expand Down
23 changes: 12 additions & 11 deletions iOS_SDK/OneSignalSDK/UnitTests/UnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -3096,19 +3096,20 @@ - (void)testHexStringFromDataWithInvalidValues {


- (void)testGetDeviceVariant {
// Simulator iPhone
var deviceModel = [OneSignalHelper getDeviceVariant];
XCTAssertEqualObjects(@"Simulator iPhone", deviceModel);

// Catalyst ("Mac")
[UIDeviceOverrider setSystemName:@"Mac OS X"];
deviceModel = [OneSignalHelper getDeviceVariant];
XCTAssertEqualObjects(@"Mac", deviceModel);

// Real iPhone
[OneSignalHelperOverrider setSystemInfoMachine:@"iPhone9,3"];
deviceModel = [OneSignalHelper getDeviceVariant];
XCTAssertEqualObjects(@"iPhone9,3", deviceModel);
#if TARGET_OS_MACCATALYST
XCTAssertEqualObjects(@"Mac", deviceModel);
#elif TARGET_OS_SIMULATOR
// Simulator iPhone
deviceModel = [OneSignalHelper getDeviceVariant];
XCTAssertEqualObjects(@"Simulator iPhone", deviceModel);
#else
// Real iPhone
[OneSignalHelperOverrider setSystemInfoMachine:@"iPhone9,3"];
deviceModel = [OneSignalHelper getDeviceVariant];
XCTAssertEqualObjects(@"iPhone9,3", deviceModel);
#endif
}

- (void)testDeviceStateJson {
Expand Down