1. Environment Configuration 1.1. Install Ant
From the Apache website, download ant, Install and configure, and add the Ant.bat directory to the PATH environment variable, such as c:\apache-ant\bin\. Run the following statement in CMD if you do not error:
>ant-h
1.2. Install git
Download git from the GIT website and install it.
1.3 Installing Nodejs
Download and install from Nodejs website, after successful installation, enter command at command line: node or NPM, no error can be made.
1.4. Installing Cordova
> NPM install-g Cordova
2. Create a project
A. Create a new folder as the working directory, cmd switch to this path
>CD D:\workspace\cordova
B. Creating Cordova Project
>cordova Create Hellocordova Com.hzjava.myCordova Hellocordova
C. Add platform Support
First, go to the project root you just created.
>CD Hellocordova
And then
> Cordova Platforms Add iOS
> Cordova Platforms Add Android
> Cordova Platforms LS
D. Add plug-ins (add plug-ins according to specific functions, such as scan code plugin, file operation plug-in, etc., you can go to Cordova Plugin library to search for plugins)
> Cordova Plugin Add com.phonegap.plugins.barcodescanner
> Cordova Plugin Add org.apache.cordova.file-transfer
> Cordova Plugin ls
Note: Not all plugins are supported by the platform, some may only support Android, some may support both Android and iOS, so you need to choose plugins carefully when developing multiplatform apps
3. Project Integration 3.1.Android
A. Copy the static HTML file to the Hellocordova\www directory
B. Compiling Android Project:
>cordova Build Android
C. Run eclipse, import the Android project under the Hellocordova\platforms\android path
D. Reference the JS Library of Cordova in HTML:
<script type= "Text/javascript" src= "Cordova.js" ></script>
<script type= "Text/javascript" src= "Cordova_plugins.js" ></script>
3.2.ios
A. Copy the static HTML file to the Hellocordova\www directory
B. Compiling iOS project:
>cordova build iOS
C. Run Xcode and import the Xcode project under the Hellocordova\platforms\ios path
D. Reference the JS Library of Cordova in HTML:
<script type= "Text/javascript" src= "Cordova.js" ></script>
<script type= "Text/javascript" src= "Cordova_plugins.js" ></script>
- Cordova compilation will copy the [root directory/www] file to the specific platform www folder, if your code is written in the platforms Android, the compilation will be overwritten
- Because the Add plugin has automatically added the relevant configuration, so as long as there is cordova_plugin.js there is no need to manually reference the Cordova plugin JS.
4. Packaging 4.1.Android
When you import a project under Platforms\android, two Project:hellocordova and Hellocordova-cordovalib appear. When packaging, copy the Hellocordova-cordovalib/bin/hellocordova-cordovalib.jar to the Hellocordova/libs folder, then right-click the main project, select Export,
Choose Export Android Application
KeyStore can create a new one yourself, or you can use an existing
Click "Finish" to successfully export APK
4.2.ios
To package an iOS installation package (IPA) that can be installed on any device, you first need an Enterprise Developer account ($299/year) to confirm that you are satisfied to perform the following steps later:
A. Login to the Apple Developer Center
B.identifiers >> app IDs, click "+", create an app ID, fill in the relevant information next
c.provisioning Profiles >> Distribution, click on the "+" number to create a profile
Select in house
Select an app ID and select the one you just created
Select a certificate
Fill in the profile name
d. Download the created profile
E. Download the certificate file selected in step c
F. Double-click the certificate and profile files in your Mac to import them
G. Open Xcode, select Project, Build Settings >> Code signing,code Signing Identity Select the registered company name
H.provisioning Profile Select the profile you just imported
I.xcode >> window >> organizer >> Archives, click Distribute
J. Select Save for Enterprise or ad hoc deployment, next
K. Select a profile to sign, and then export
Cordova Configuration and development