Current location - Quotes Website - Signature design - Why does the cordova command installation error occur on ios?
Why does the cordova command installation error occur on ios?

ios development environment configuration, cordova installation and common commands

1. ios development environment configuration

1. First, you must have a Mac Book. If you have a Mac Book , skip steps 2, 3, and 4. If not, perform steps 2, 3, and 4;

2. Download and install VMware Workstation, preferably the latest version;

3. Download and install unlock-all (VMware Workstation restricts the installation of Mac virtual machines by default, you need to install this file to remove the restriction);

4. Download the image file of the Mac OS operating system (it needs to be an .ios file ) If you download a .dmg file, you need to use the anytoiso.exe tool to convert it into an .ios file. After the download is complete, install it on VMware Workstation;

5. Install XCode;

6. Install the .p12 file;

7. Apply for bundle id;

8. Set up a developer account in XCode;

9. Download and bundle in XCode Description file corresponding to id;

2. Cordova installation and common commands

1.1 Install nodejs

Download and install from the nodejs website. After the installation is successful, in the command Enter the command: node or npm, and no error will be reported.

1.2 Install cordova

> npm install -g cordova

2. Create a project

a. Create a new folder as the working directory , cmd switches to this path

>cd d:\workspace\cordova

b. Create cordova project

>cordova create helloCordova com.hzjava.myCordova HelloCordova

c. Add platform support

First enter the root directory of the newly created project

>cd helloCordova

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 For code scanning plug-ins, file operation plug-ins, etc., you can go to the cordova plug-in library to search for the required plug-ins)

> 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 all platforms, some may only support android, and some may support both android and ios, so you need to choose plug-ins carefully when developing multi-platform apps

3. Project integration

3.1. Android

a. Copy the static html file to helloCordova\ Under the www directory

b. Compile the android project:

>cordova build android

c. Run eclipse and import the android project under the helloCordova\platforms\android path

d. Reference cordova’s js library in html:

3.2.ios

a. Copy the static html file to helloCordova \www directory

b. Compile the ios project:

>cordova build ios

c. Run xcode and import the xcode project under the helloCordova\platforms\ios path

d. Reference cordova’s js library in html:

Cordova compilation will copy the files under [root directory/www] to the www file of the specific platform folder, if your code is written in Android in platforms, it will be overwritten during compilation

Because the relevant configuration has been automatically added when adding plugin, so as long as there is cordova_plugin.js, there is no need Manually reference the js of the cordova plug-in.

4. Packaging

4.1.Android

When importing the project under platforms\android, two projects will appear: HelloCordova and HelloCordova-CordovaLib.

When packaging, copy HelloCordova-CordovaLib/bin/hellocordova-cordovalib.jar to the HelloCordova/libs folder, then right-click the main project and select Export

Select Export Android Application

Keystore can create a new one or use an existing one

Click "Finish" to successfully export the apk

4.2.ios

To package it into any device The ios installation package (ipa) that can be installed first requires an enterprise developer account ($299/year). After confirming that it is satisfied, follow the following steps:

a. Log in to the Apple Developer Center

< p>b.Identifiers >> App IDs, click the "+" sign to create an app id, fill in the relevant information and click the next step

c.Provisioning Profiles >> Distribution, click the "+" sign to create A profile

Select In House

Choose an app id and select the one you just created

Select a certificate

Fill in the profile name< /p>

d. Download the created profile file

e. Download the certificate file selected in step c

f. Double-click the certificate and profile files on mac to copy them Import

g. Open xcode, select the project, Build Settings >> Code Signing, Code Signing Identity, select the registered company name

h.Provisioning Profile, select the profile just imported

i.xcode >> window >> Organizer >> Archives, click Distribute

j. Select save for enterprise or ad hoc deployment, next step

k. Select one profile to sign and then export