How to run a XUL application in Mac OS X Snow Leopard?
I am trying to create a XUL "Hello World" application in Mac OS X. I download the XULRunner from here, followed this tutorial and then this tutorial and then this tutorial... None worked. So, I looked at it better and found this section, whose instructions I followed. Unfortunately, it does not work yet. I even can run the application with the command
/Library/Frameworks/XUL.framework/xulrunner-bin $PWD/application.ini
However, no window is presented and no error is printed. It happens when I try to run the application with firefox -app
too.
What can be wrong? Also, does someone know some tutorial which would work? It would be an acceptable answer, too :)
Thanks in advance!
File contents
The content of the application.ini
file is:
[App]
Vendor=Me
Name=Zull
Version=1.0
BuildID=31052011
ID=zull-xul@zull.com
[Gecko]
MinVersion=2.0
MaxVersion=2.*
The content of chrome/chrome.manifest
is:
content zull file:content/
The content of chrome/content/main.xul
is:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" 开发者_StackOverflowtitle="My App" width="300" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<caption label="Hello World"/>
</window>
Finally, the content of defaults/preferences/prefs.js
is:
pref("toolkit.defaultChromeURI", "chrome://zull/content/main.xul");
I can see only one obvious mistake here. The contents of your chrome.manifest file should be:
content zull content/
Generally, you can always add the -jsconsole
flag to the command line. This will open the Error Console and will often show you what's wrong.
Following the recommendations of Wladimir Palant, I changed the content of chrome/chrome.manifest
from
content zull file:content/
to
content zull content/
Then, following these instructions, I created a chrome.manifest
file in the root app dir whose content is
manifest chrome/chrome.manifest
It is required because the default place for chrome.manifest
in XULRunner 2.0 is the root app directory.
However, the error No chrome package registered for chrome:///User/brandizzi/sandbox/zull/main.xul
persisted. Then, I got it: trying to solve the problem, I experienced using the full path to the main.xul
file in defaults/preferences/prefs.js
:
pref("toolkit.defaultChromeURI", "chrome:///User/brandizzi/sandbox/zull/main.xul");
I just changed it to the chrome path...
pref("toolkit.defaultChromeURI", "chrome://zull/content/main.xul");
...and it worked.
It was a bunch of silly errors nonetheless but it is solved now. This thread was very helpful to me. Also, Wladimir recommendation about using the -jsconsole
option of XULRunner (such as in /Library/Frameworks/XUL.framework/xulrunner-bin ~/sandbox/zull/application.ini -jsconsole
) was very useful.
精彩评论