Code sign bundled app made with osacompile

喜欢而已 提交于 2019-12-12 02:58:21

问题


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

  1. Open the Script Editor
  2. Write some AppleScript (do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager &> /dev/null &")
  3. Save your new AppleScript > Save As > Application Bundle
  4. 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

  1. 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 &"'
    );
    
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!