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

macOS: Added warning for non-signed M1 apps #431

Merged
merged 1 commit into from
Aug 1, 2022
Merged
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
50 changes: 34 additions & 16 deletions platform/mac/OSXAppBuildController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "Core/Rtt_Build.h"

#include <sys/sysctl.h>

#import "OSXAppBuildController.h"

#import "AppleSigningIdentityController.h"
Expand Down Expand Up @@ -169,6 +171,34 @@ - (BOOL)isDeveloperBuild
|| [[NSUserDefaults standardUserDefaults] boolForKey:@"macOSIgnoreCertType"]);
}

- (void)checkAndWarnARM //Apple Silicon(Arm) computers require signing to test locally
{
//Check for ARM
cpu_type_t type;
size_t size = sizeof(type);
sysctlbyname("hw.cputype", &type, &size, NULL, 0);
cpu_type_t typeWithABIInfoRemoved = type & ~CPU_ARCH_MASK;
IdentityMenuItem* item = currentProvisioningProfileItem;

if (typeWithABIInfoRemoved == CPU_TYPE_ARM && ![[NSUserDefaults standardUserDefaults] boolForKey:@"macOSARMSignWarn"] && item == [fSigningIdentities itemAtIndex:1])
{
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"WARNING: Signing Required to run App"];
[alert setInformativeText:@"Apple requires Apple Silicon(ARM) based Apps to be signed in order run on Apple Silicon(M1) based Macs"];

[alert addButtonWithTitle:@"Ok"];
[alert setShowsSuppressionButton:YES];
[alert runModal];

if(alert.suppressionButton.state == 1){
[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"macOSARMSignWarn"];
}


}

}

- (void)willShowAlert:(NSAlert*)alert
{
NSString *validationMessage = nil;
Expand Down Expand Up @@ -290,6 +320,10 @@ - (IBAction)build:(id)sender
{
return;
}

if( [self isDeveloperBuild] ){
[self checkAndWarnARM];
}

NSWindow *buildWindow = [self window];

Expand Down Expand Up @@ -427,26 +461,10 @@ - (IBAction)build:(id)sender
params->SetStripDebug( isStripDebug );
params->SetRuntime([appDelegate runtime]);

#ifdef AUTO_INCLUDE_MONETIZATION_PLUGIN
// Manual enabling of inclusion of Fuse plugins
BOOL includeFusePlugins = NO;
NSString *includeFusePluginsStr = [[NSUserDefaults standardUserDefaults] stringForKey:@"debugMonetizationPlugin"];

if (includeFusePluginsStr != nil)
{
includeFusePlugins = [includeFusePluginsStr boolValue];
}

// params->SetIncludeFusePlugins( includeFusePlugins );

// params->SetUsesMonetization( ([fEnableMonetization state] == NSOnState) );
#endif // AUTO_INCLUDE_MONETIZATION_PLUGIN

// Some IDEs will terminate us quite abruptly so make sure we're on disk before starting a long operation
[[NSUserDefaults standardUserDefaults] synchronize];

// Do the actual build

[self logEvent:@"build"];

NSString* tmpDirBase = NSTemporaryDirectory();
Expand Down