Building a Crosswalk application

原文访问实在太慢,转载到这里方便访问。

Building a Crosswalk application

Crosswalk is a runtime for HTML5 applications. This means that any existing HTML5 applications should run on Crosswalk, providing they already run in a modern browser (Chrome, Firefox, Safari).

For the purposes of this tutorial, we use the simplest possible Crosswalk application: one HTML file.

However, because Crosswalk applications are intended to integrate well with the target environment, they require an additional file, manifest.json , containing metadata for that purpose. The manifest can be used to specify icons to use at different resolutions, set an app description, adjust content security policy settings, and otherwise configure how the app integrates with the target environment.

A simple application

1.First, create a directory called xwalk-simple for the project:

> mkdir xwalk-simple/
> cd xwalk-simple/

2.Next, copy an icon file to that directory, to serve as the application icon. You can use this icon:

To use this example, right click on the image and select Save Image As… (or its equivalent in your browser). Save it into the xwalk-simple directory as icon.ico. (Note that this image is from the Crosswalk source code and is BSD licensed.)

If you have your own favourite icon, copy that to the xwalk-simple directory instead. It should be 96 pixels square or larger.

3.Create two text files inside xwalk-simple. (Create them using any text editor, such as Notepad.):

  • index.html

This is a single HTML file which represents the user interface for the application. For the purposes of this tutorial, we are not using any CSS or JavaScript.

The content should be:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <title>simple</title>
  </head>
  <body>
    <p>hello world</p>
  </body>
</html>
  • manifest.json

This contains the application metadata (see above).

The content should be:

{
  "name": "simple",
  "xwalk_package_id": "com.app.simple",
  "xwalk_version": "0.0.1",
  "start_url": "index.html",
  "icons": [
    {
      "src": "icon.ico",
      "sizes": "96x96",
      "type": "image/vnd.microsoft.icon",
      "density": "4.0"
    }
  ]
}

See the manifest documentation for more information.

4.From inside the xwalk-simple directory, run:

> crosswalk-pkg --platforms=windows .

The crosswalk-pkg command above can be run from any location by putting the path to your project directory as the last parameter.

This will download the Crosswalk libraries, package the application defined in the specified manifest.json file and produce an .msi (in our example com.app.simple-0.1.0.0.msi). The .msi is currently a 64-bit build of Crosswalk for Windows and will only run on 64-bit Windows. Once you’ve done this, you’re ready to run the application on a target.

What’s next?

Run on Windows

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值