Learn how to quickly add the mobile platforms you wish to create mobile applications for, such as iOS and Android.
- View Offline
- [Voiceover] With our shell Cordova app created through the CLI, let's go ahead and build our sample app. Before we can do that, we need to change our working directory to be the project's directory that we created. All of our Cordova and PhoneGap CLI commands need to be read from within this directory. So, cd myApp. Next we need to include the platforms we wish to build for. Let's first add iOS. The command for this is cordova platform add ios.
And after a few moments, the iOS projects is added. Now let's go ahead and add Android as well. So it's cordova platform add android. Now, let's go ahead and take a look at the platform's directory within our actual application. So, go in to Platforms. We now see we have both an Android and iOS folder within our platform's directory for our app. Matter of fact, if we go ahead and open the iOS version we can see we actually have an extra project already scaffold for us.
Before the CLI, we would've had to create this project ourselves and apply all the various Cordova specific elements. This was never an easy project. Let's go ahead and open the xcode project real fast. With our project now off an xcode, I can now click the Run button, and it will actually compile our application with an ex code. Our build was successful, in a moment it should launch the simulator. I've switched over to the simulator, our sample PhoneGap app is now running inside there.
And there we have our sample Cordova CLI app running in the iOS simulator built through xcode. Now don't worry, you don't need to use xcode every time you want to run your app in this simulator. There's a solution for that that we'll sell in just a little bit. Let me go back and quit this, go ahead and quit xcode, come back over to our platform directory, move up, Android, and the exact same thing. Since we can also develop Android applications of various IDE's, like the Android Studio, or an older version such as Eclipse.
The process surfing goes into those IDE's does take a few more steps, and will vary depending on which IDE you use. So, if you actually do wanna take this into say Android Studio, go ahead and consult the Cordova platform guides relay some information on how to do it. But the reason you're using the CLI is to avoid having to touch either one of these IDE's as much as possible.
- What is Apache Cordova?
- Setting up for Android or iOS development on Windows and Mac
- Installing the command-line interfaces (CLIs) for Cordova and PhoneGap
- Creating a Cordova project
- Adding and removing platforms from a project
- Working with metatags
- Configuring your app
- Building the app
- Extending an app with plugins
- Preparing for release
- Upgrading to PhoneGap desktop