Cordova lesson 3: Add Platforms


All subsequent commands need to be run within the project’s directory, or any subdirectories:

$ cd hello
Add the platforms that you want to target your app. We will add the ‘ios’ and ‘android’ platform and ensure they get saved to config.xml and package.json:

$ cordova platform add ios
$ cordova platform add android

Result:

D:\Cordova\zship>cordova platform add android
Using cordova-fetch for cordova-android@~7.0.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.zship.hello
        Name: zship
        Activity: MainActivity
        Android target: android-26
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@7.0.0
Android Studio project detected
Android Studio project detected
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the pro
ject
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android gr
eater than 4.0. If you have a previous platform version, you do *not* need this
plugin since the whitelist will be built in.

Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving android@~7.0.0 into config.xml file ...
D:\Cordova\zship>cordova platform add ios
Using cordova-fetch for cordova-ios@~4.5.4
Adding ios project...
Creating Cordova project for the iOS platform:
        Path: platforms\ios
        Package: com.zship.hello
        Name: zship
iOS project created with cordova-ios@4.5.4
Installing "cordova-plugin-whitelist" for ios
--save flag or autosave detected
Saving ios@~4.5.4 into config.xml file ...

cordova platforms

To check your current set of platforms:

$ cordova platform ls

D:\Cordova\zship>cordova platform ls
Installed platforms:
  android 7.0.0
  ios 4.5.4
Available platforms:
  browser ~5.0.1
  osx ~4.0.1
  windows ~5.0.0
  www ^3.12.0

Running commands to add or remove platforms affects the contents of the project’s platforms directory, where each specified platform appears as a subdirectory.

Note: When using the CLI to build your application, you should not edit any files in the /platforms/ directory. The files in this directory are routinely overwritten when preparing applications for building, or when plugins are re-installed.

To remove platform:

D:\Cordova\zship>cordova platform remove ios
Removing platform ios from config.xml file...
Removing ios from cordova.platforms array in package.json

Leave a Reply