I’ve been putting together a simple launcher app for a game jam I’m hosting, and I’ve found that File::startAsProcess doesn’t work on OSX if you try and launch a bundle and pass it arguments.
Disclaimer: my knowledge of objective c is minimal and it’s possible that the following contains various errors.
The problem seems to be that in Process::openDocument, you’re using openURLs when you detect that the passed-in fileName is a bundle. As far as I can tell though, this doesn’t run an executable with arguments, but rather attempts to run multiple executables. I believe the correct function for this purpose is launchApplicationAtURL:
[code]NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
StringArray docs;
docs.addTokens (parameters, true);
NSMutableArray* paramArray = [[NSMutableArray alloc] init];
for (int i = 0; i < docs.size(); ++i)
[paramArray addObject: juceStringToNS (docs[i])];
[dict setObject:paramArray forKey:NSWorkspaceLaunchConfigurationArguments];
ok = [[NSWorkspace sharedWorkspace] launchApplicationAtURL: [NSURL URLWithString: juceStringToNS (fileName)]
options: NSWorkspaceLaunchDefault|NSWorkspaceLaunchNewInstance
configuration: dict
error: nil];
[/code](there seems to be an additional problem with your use of openURLs in that you never actually pass fileName to the function, but that’s a bit beside the point)
The above works perfectly for me. The only problem is that launchApplicationAtURL is only available for 10.6 and higher; I don’t know how much of an issue that is these days.
