On Dec 7, 2014, at 2:29 PM, SevenBits <sevenbitst...@gmail.com> wrote:
> I have a sandboxed app destined for the Mac App Store. Inside of it is an > embedded console program which I want to open in Terminal (i.e Terminal.app > opens and the app runs in its window). Here’s what I’m doing: > > NSString *interactiveExecutablePath = [[[NSBundle mainBundle] bundlePath] > stringByAppendingPathComponent:@"/Contents/MacOS/app"]; > [NSTask launchedTaskWithLaunchPath:@"/usr/bin/open" arguments:@[@"-a", > @"Terminal", interactiveExecutablePath]]; First, it never makes any sense for a program to spawn a subprocess to run /usr/bin/open. /usr/bin/open is just a wrapper around Launch Services. So, you could just call Launch Services directly or use NSWorkspace, which is also a wrapper around Launch Services. Second, even using Launch Services isn't the best way to do this (sandbox issues aside). It's better to run the equivalent of this AppleScript script: tell app "Terminal" activate do script "your command goes here" end You can do that using NSAppleScript or the Scripting Bridge. I don't know if this approach is more likely to work in a sandboxed app. I doubt it, because it would be an enormous hole in the sandbox. If you can direct Terminal to run arbitrary commands, what protection does the sandbox provide? > I really need this to work as it’s an important aspect of my application. Can > anyone advise? I suspect you have a serious problem, then. You will probably need to deploy outside of the Mac App Store so that you don't have to sandbox your app. Alternatively, you can build a terminal emulator UI into your app and run the embedded console program within that, instead of Terminal. Depending on the needs of your console program, that may be a relatively straightforward prospect or a very complex one. Regards, Ken _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com