refactor: migrate electron_login_helper to non-deprecated API (#43182)

refactor: migrate electron_login_helper to non-deprecated API
This commit is contained in:
Shelley Vohr 2024-08-05 09:56:18 +02:00 committed by GitHub
parent 78995b956e
commit 2a613cabaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,12 +4,6 @@
#import <Cocoa/Cocoa.h>
// launchApplication is deprecated; should be migrated to
// [NSWorkspace openApplicationAtURL:configuration:completionHandler:]
// UserNotifications.frameworks API
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
int main(int argc, char* argv[]) {
@autoreleasepool {
NSArray* pathComponents =
@ -17,11 +11,18 @@ int main(int argc, char* argv[]) {
pathComponents = [pathComponents
subarrayWithRange:NSMakeRange(0, [pathComponents count] - 4)];
NSString* path = [NSString pathWithComponents:pathComponents];
NSURL* url = [NSURL fileURLWithPath:path];
[[NSWorkspace sharedWorkspace] launchApplication:path];
[[NSWorkspace sharedWorkspace]
openApplicationAtURL:url
configuration:NSWorkspaceOpenConfiguration.configuration
completionHandler:^(NSRunningApplication* app, NSError* error) {
if (error) {
NSLog(@"Failed to launch application: %@", error);
} else {
NSLog(@"Application launched successfully: %@", app);
}
}];
return 0;
}
}
// -Wdeprecated-declarations
#pragma clang diagnostic pop