问题
Programmatically I trying to achieve this on Mac OS X: a file on desktop that when clicked will launch Firefox with a certain profile.
I do this with AppleScript and bash.
Manual steps
- Open the Script Editor
- Write some AppleScript (
do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager &> /dev/null &"
) - Save your new AppleScript > Save As > Application Bundle
- Set icon
This works perfectly fine manually it follows this tutorial: Asa Dotzler Blog Firefox Shortcut
However programmatically I'm having some problems.
I successfully make the file and put it on desktop with /bin/bash/osacompile -
.
Programmatic Steps
Programmatic Step 1 - create a script.txt file with the code on desktop
var path_src = OS.Path.join( OS.Constants.Path.desktopDir, 'script.txt' ); var path_exe = FileUtils.getFile('XREExeF', []).path; var write_file = OS.File.writeAtomic( path_src, 'do shell script "' + path_exe + ' -P -no-remote &> /dev/null &"' );
Compile the .txt to .app and put it on desktop code:
var path_compile = OS.Path.join(OS.Constants.Path.desktopDir,'script.app'); var osacompile = File.initWithPath("/usr/bin/osacompile"); if (MacVersion <= 10.6) { osacompile.arguments = ["-o", path_compile, path_src] } else { //for >= 10.7 osacompile.arguments = [ "-t", "osas", "-c", "ToyS", "-o", path_compile, path_src ] } osacompile.run();
But when user clicks it they get this error:
""script" can't be opened because it is from an unidentified developer."
Image:

I heard maybe this can be code signed? How can I code sign it so I can bypass this error and start working on setting icon?
回答1:
A simple google search for "applescript code sign" turns up lots of info.
Another option: if the code is to run on your computer you can just turn off the system preference that causes this. Go to Security & Privacy->General and choose the checkbox "allow apps downloaded from anywhere". Of course realize that this will do exactly what it says so it's a possible security issue. I run my computer this way but you may feel differently.
So either method will solve your issue. Good luck.
来源:https://stackoverflow.com/questions/25859379/code-sign-bundled-app-made-with-osacompile