Getting start with Cordova for MacOS

Yang Nana
3 min readOct 22, 2018

--

My computer is macOS High Sierra Version 10.13.5

Install the Cordova CLI

  1. Download and install Node.js

2. Install cordova module using npm

Create the App

Go to the directory you want o maintain yoursource code, and create a project

cordova create hello com.example.hello HelloWorld

Add platform

Firstly, I check whatever platform it is support

cd hello
cordova platform ls

Then I add ios and android platform

cordova platform add ios
cordova platform add android
cordova platform ls

Install pre-requisites for building

To check if mine satisfy requirements for building the platform

cordova requirements

As the two errors above, I install the gradle and ios-deploy

For IOS case:

npm install -g ios-deploy

For Android case:

brew install gradle

Then I check the requirement again

Build the App

To build all platforms:

cordova build

To build specific platform, i.e ‘ios’

cordova build ios

If there is error in ios case like this

You need to open the workspace file in xcode and choose your team developer. Then, build again

iOS succeed
Android build succeed

Test the App on Emulator

  1. Run emulator (if for Android)

2. Run this command to rebuild the app and view it in Android/ iOS

cordova emulate android
cordova emulate ios

Test the App on Device

cordova run android
cordova run ios

New ios version problem

For new version, it is possible we can’t build and run it. There is a workround for it:

Create a build.json file and write down these to the file:

{
"ios": {
"debug": {
"developmentTeam": "your_team_id",
"buildFlag": [
"-UseModernBuildSystem=0"
]
},
"release": {
"developmentTeam": "your_team_id",
"buildFlag": [
"-UseModernBuildSystem=0"
]
}
}
}

Then try again.

--

--