It is relevant to my app to have a button in my app's Preferences window to launch the System Preferences app. The reason why doing this is relevant is because there is a setting in System Preferences that affects my app, however my app cannot provide a user interface that allows the user to change this preference. So they have to go to System preferences.
I activate the System Preferences app and set the current pane to pane "pane here". I can run this in the Script Editor and it works fine. But if I copy the script on my apps main bundle and do:
NSURL *appleScriptURL = [[NSBundle mainBundle]URLForResource:@"SriptHere" withExtension:@"scpt"];
NSAppleScript *appleScript = [[NSAppleScript alloc]initWithContentsOfURL:appleScriptURL error:&errorInfo];
NSAppleEventDescriptor *descriptor = [appleScript executeAndReturnError:&errorInfo];
I get
NSAppleScriptErrorMessage = "System Preferences got an error: Application isn\U2019t running.";
NSAppleScriptErrorNumber = "-600";
Is this because of the app is sandboxed? And if so, is there a supported way to open a System Preference pane in a sandboxed environment..I know I can just launch System Prefs with NSWorkspace...but I'd like to set the right pane to make it nice on users. (EDIT: Yes...the script works if I turn App sandboxing off...so the sandbox is blocking it).