Cordova5, cordova

Source: Internet
Author: User
Tags install node

Cordova5, cordova
Since the company's recent project requires Cordova for development, it began to learn Cordova. As I have previously developed iOS, I mainly write the content from the perspective of iOS platform. I just started to learn about the Cordova platform. I hope to summarize what I learned and provide some reference to people who need it. please correct me if you have any improper information. There are many discussions about whether an App is Native, Web, or Hybrid, and Cordova is a framework that provides Web developers with fast mobile application development. Its predecessor was Adobe's PhoneGap framework, which then contributed to the Apache community as an open-source project. Cordova not only enables technical personnel familiar with Web development to easily develop mobile applications, but also allows original Native mobile application developers to integrate Web pages and integrate Web pages through plugin (in) implementing the interoperability between underlying device resources and js is an ideal solution for Hybrid or Web App, which can achieve low-cost and rapid development of apps.

  • 1. Establish the environment
  Install Xcode:You can download and install the latest version in the AppStore. Install Node. js: It is mainly used to download and install Cordova. Note: Do not download the latest version 4.x. x. The version may be too new to install cordova. The following versions have been confirmed to be available. : Directly run the Installation File pkg after the https://nodejs.org/download/release/v0.12.7/ download, keep "continue" until the installation is successful. Running npm-v on the terminal indicates that the version number is successful. Then you can install Cordova. Install Cordova CLI: 
Sudo npm install-g cordova or sudo npm install-g cordova@x.x.x to install the specified version
Note: The latest version is 5.3.3. Update Cordova: 
sudo npm update cordova -g
If the download fails, use the following method to reference the domestic image site:
npm config set registry http://registry.cnpmjs.org npm info cordova  npm --registry http://registry.cnpmjs.org info cordova
Installation success screen: or enter:
cordova -v  
The version number indicates that the installation is successful. The iOS platform-based environment is relatively easy. After completing the above steps, the environment is set up.
  • 2. Create the first Cordova Project
Open the terminal, cd to the corresponding path, and enter:
$cd ~/Documents $cordova create hello com.example.hello HelloWorld
Add-d to display the details of Project Creation. The first parameter hello is the folder name of the project; the second parameter (optional) com. example. hello is the Application id, which is similar to that in Xcode. modified in xml. If not specified, the default value is io. cordova. hellocordova; the third parameter (optional) HelloWorld is the name displayed by the App, which can also be found in config. in xml. After the creation is successful, open the hello directory to view the following structure: | -- conig. xml // the configuration file of cordova | -- hooks // the script file that stores the custom cordova command. | -- README. md | -- platforms // native Engineering Code of each platform, which will be overwritten during build without modification | -- plugins // plug-in directory (mainly to provide native APIs of each platform) | -- www // source code directory written in H5, which is placed in the assets \ www directory of each platform during build. | -- Css/| -- img/| --index.html // html file of the App portal | -- js/
  • 3. Added iOS platform support
Enter: Enter the project directory in the terminal:
$ cd hello
Add an iOS platform file:
$cordova platform add ios
You can also add other platforms, such:
$cordova platform add android

 

Adding ios project...
IOS project created with cordova-ios@3.9.1
Discovered plugin "cordova-plugin-whitelist" in config. xml. Installing to the project
Fetching plugin "cordova-plugin-whitelist @ 1" via npmInstalling "cordova-plugin-whitelist" for ios. The following path is added to the platforms Folder: | -- platforms. json | -- ios/| -- cordova/| -- CordovaLib/| -- HelloWorld/| -- platform_www/| -- www/| -- helloWorld. xcodeproj can directly open HelloWorld. the xcodeproj project is compiled and run in Xcode. The running result is as follows: References:Http://rensanning.iteye.com/blog/2016364http://cordova.apache.org/docs/en/5.1.1/guide/overview/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.