How to package a standalone xulrunner app for OS X?

耗尽温柔 提交于 2019-12-06 12:27:48

You are on the right track, there is just one major issue you are facing.

If you were to run you application by the command line, you would get some output like this.

$ SampleApplication.app/Contents/MacOS/xulrunner
Mozilla XULRunner 33.0

Usage: xulrunner [OPTIONS]
       xulrunner APP-FILE [APP-OPTIONS...]

OPTIONS
      --app                  specify APP-FILE (optional)
  -h, --help                 show this message
  -v, --version              show version
  --gre-version              print the GRE version string on stdout

APP-FILE
  Application initialization file.

APP-OPTIONS
  Application specific options

As we can see, the executable did not automatically run the Contents/Resources/application.ini like the tutorials say it will. This is a known issue, and the popular workaround among XULRunner users is to create a stub shell script to pass the required argument to the xulrunner binary.

Here is a script I've whipped up to do just that.

#!/bin/sh

runpath="`dirname "$0"`"
contentsdir="`cd "$runpath"/.. > /dev/null && pwd`"
exec "$runpath/xulrunner" --app "$contentsdir/Resources/application.ini"

Save this text to a file in your MacOS directory and give it executable permissions. For sake of example, I will use sampleapplication. Here is the command to set executable permissions.

chmod +x sampleapplication

Now, modify your Info.plist to execute this script instead of executing xulrunner directly by setting the CFBundleExecutable entry to match your stub shell script.

    <key>CFBundleExecutable</key>
    <string>sampleapplication</string>

Now when you run your application, it should work. If you are getting an error saying "The application cannot be opened because its executable is missing", you may want to rename the application bundle, or follow the advice in that question to avoid the caching issue.

Bonus Info

You can remove the Contents/Frameworks/XUL.framework directory, it is no longer used and placing the XUL.framework contents in the MacOS folder is now the correct place to put them.

You should also copy the dependentlibs.list file from the Contents/MacOS to the Contents/Resources directory, although XULRunner 33 seems to be getting on fine without it.

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