We've created our first projects, but we haven't specified the platforms that the projects support. We'll add the iOS and Android platforms in this step and also show you how to manage the available platforms in your project.
It's important for your computer to be connected to the Internet as, while adding platforms, you may need to download platform-specific code.
After creating your project, the next step usually involves adding the platforms the project will support. However, it's important to remember that you can also manage these platforms at any time. You can remove platforms, update platforms (in the case of an update to Cordova), and list out the supported platforms.
To add the iOS and Android platforms (regardless of which CLI you used to create your project), open your terminal or command prompt, navigate to your project's directory, and type this:
cordova platform add ios android
Tip
Windows / Linux Users
You won't be able to add the ios
platform, so just use cordova platform add android
.
There may be a delay since each Cordova platform may need to download various platform files from the Internet. If you want to add other platforms, you can follow this pattern:
cordova platform add platform-name
Here, platform-name
is any of the supported platforms, including the following:
ios
: The iOS platformandroid
: The Android platformblackberry10
: The BlackBerry 10 OS platformfirefoxos
: The Firefox OS platformwp7
: The Windows Phone 7 platformwp8
: The Windows Phone 8 platformwindows
8
: The Windows 8 platform
Tip
In order to build or deploy a project for a given platform, you need to have the appropriate platform SDK installed and properly configured. If not, you may receive errors.
Lots of new files have been added in the merges, platforms, and plugins folders. These are the platform-specific portions of your project.
At some point in the future, you may want to ask Cordova which platforms your project is configured to support. To find out, just type the following command:
cordova platform ls
You'll see output similar to this:
Installed platforms: android, ios Available platforms: blackberry10, firefoxos
To remove a platform, just type this:
cordova platform remove platform-name
This will remove the appropriate directories and files from your project.