Browse Source

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

refactor: migrate electron_login_helper to non-deprecated API
Shelley Vohr 8 months ago
parent
commit
2a613cabaa
1 changed files with 11 additions and 10 deletions
  1. 11 10
      shell/app/electron_login_helper.mm

+ 11 - 10
shell/app/electron_login_helper.mm

@@ -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