官术网_书友最值得收藏!

Building and deployment

Once you are done with your development, you might want to test the application on a real mobile device. Each mobile platform will have a different kind of binary format for the applications. For example, Android application files will have the .apk extension. Similarly, each platform will have a different format for the application.

To create binary files for all platforms from your source code, you need to build the application either locally or by using a cloud service.

If you are building the application locally, you need to run the command-line interface, and the required platform's SDK should be installed on the machine. The CLI supports the following combinations on each operating system:

This table makes it clear that you can't build an iOS application on a Windows machine or a Windows 8 application on a Mac machine. You will need an appropriate machine and the required SDKs installed on the machine.

Assuming you have all the required SDKs installed and configured, to build the application for each of the platform, you can use the build tool of CLI.

Run the following command to build the project for all the platforms added to the project. If you added multiple platforms to the project using the platform add command, the build will happen for all platforms:

C:\example1> phonegap build

If you want to build the application only for a particular platform, say Android or iOS, you can target them inpidually with the following commands:

C:\example1> phonegap build android
C:\example1> phonegap build ios

The build command is the shortcut to prepare and compile the project. You can also build a project in two steps, as shown here. The following set of commands is the equivalent of the build command:

C:\example1> phonegap prepare android
C:\example1> phonegap compile android

Once the build process is completed, the platform-specific app will be available within the project's platforms subdirectory.

Having seen the manual way of building an application, now let's find out about PhoneGap Build. If you want to build and generate application binary files for all platforms, you need to install the inpidual SDKs on your machine, which is not practically possible. That's where we find the PhoneGap Build process handy. PhoneGap Build is an online service for creating binary files for all mobile platforms based on a single source code.

It takes the source code and creates the app file for each of the platforms that you require. It's as simple as uploading your Cordova/PhoneGap project and the cloud service does the rest. The overall functionality of the PhoneGap Build process is provided in the following diagram, which is available at https://build.phonegap.com:

To use PhoneGap Build, you have to follow these steps:

  1. Complete your PhoneGap/Cordova project and ensure you have all the functionalities included in the app as per your design.
  2. PhoneGap Build only requires the contents (HTML, CSS, JavaScript, and images) of your project's assets directory.
  3. If you have any phonegap.js or cordova.js files included in your assets, remove the file as the PhoneGap Build process will automatically inject the required file.
  4. You can upload the project to the PhoneGap Build process and you can see the magic happen.

You can easily download all the application builds for all platforms with a single click:

More details about the PhoneGap Build process can be obtained at http://docs.build.phonegap.com/en_US/.

主站蜘蛛池模板: 蕉岭县| 景泰县| 浏阳市| 天柱县| 吉隆县| 山东省| 伊金霍洛旗| 灵寿县| 南充市| 沭阳县| 阿瓦提县| 富顺县| 南安市| 奇台县| 田东县| 锡林浩特市| 吉林省| 海丰县| 景洪市| 双辽市| 利辛县| 东源县| 收藏| 峡江县| 贵港市| 凤翔县| 平谷区| 兴和县| 敦化市| 怀化市| 沾益县| 上林县| 鄄城县| 阿拉尔市| 宝坻区| 彭水| 舟曲县| 池州市| 昔阳县| 高雄县| 衡山县|