Reputation: 654
I am trying to launch one of my apps(say app2) from another of my apps(say app1) on my Mac OS X 10.7.4. I am using the below code for the same:
[ [ NSWorkspace sharedWorkspace ] launchApplicationAtURL:[NSURL fileURLWithPath:appPath] options:NSWorkspaceLaunchDefault configuration:[NSDictionary dictionaryWithObject:[NSArray arrayWithObject: @"mode"] forKey:NSWorkspaceLaunchConfigurationArguments] error:&err];
This works fine except for the first time i.e. if we have a new machine, then the first attempt for launching the app2 from app1 fails when tried for the first time when logged in as root user but works fine subsequently.
Below is the error I get on dumping the NSError:
2012-11-05 07:47:48 +0000: The application “App2” could not be launched because a miscellaneous error occurred (OSStatus -10810).
Also, I get the below messages in "All Messages" in Console:
11/4/12 11:47:48.329 PM com.apple.launchd[1]: System: Bug: 12B19: launchd + 79534 [AEF41441-17BC-36E6-B1F8-57BADBDFEBCF]: 0x0
11/4/12 11:47:48.329 PM com.apple.launchd[1]: System: This API can only be used by a process running within an Aqua session.
11/4/12 11:47:48.329 PM App1[2405]: spawn_via_launchd() failed, errno=5 label=[0x0-0x57057].com.ak.app1 path=/var/root/Library/Caches/com.ak.app2/app2.app/Contents/MacOS/app2 flags=0
The strange think is that it only fails for the first attempt with root user.
Upvotes: 4
Views: 2227
Reputation: 2616
You appear to be attempting to launch an application from a non-UI process. This is no longer supported, as it uses LSOpenApplication
internally, which does not support non-UI processes since Lion. Please see this discussion for more info
Upvotes: 2