iOS
Requirements and Support
Apple® tools required to build iOS applications only run on the OS X operating system on Intel-based Macs. Xcode® 7.0 (the minimum required version) runs only on OS X version 10.10.4 (Yosemite) or greater, and includes the iOS 9 SDK (Software Development Kit). To submit apps to the Apple App Store℠ requires the latest versions of the Apple tools.
You can test many of the Cordova features using the iOS simulator installed with the iOS SDK and Xcode, but you need an actual device to fully test all of the app's device features before submitting to the App Store. The device must have at least iOS 8 installed, the minimum iOS version supported as of Cordova 4.0.0. Supported devices include iPhone 4S, iPhone 5, iPhone 5C, iPhone 5S, iPhone 6, iPhone 6 Plus, iPhone 6S, iPhone 6S Plus, iPhone SE, iPad 2, iPad 3, iPad 4, iPad Air, iPad Air 2, iPad Pro, iPad Mini, iPad Mini 2, iPad Mini 3, iPod Touch 5th gen and iPod Touch 6th gen or later.
Installing the Requirements
Xcode
There are two ways to download Xcode:
- from the App Store, available by searching for "Xcode" in the App Store application
- from Apple Developer Downloads, which requires registration as an Apple Developer.
Once Xcode is installed, several command-line tools need to be enabled for Cordova to run. From the command line, run:
$ xcode-select --install
Deployment Tools
- The ios-deploy tools allow you to launch iOS apps on an iOS Device from the command-line.
- To install it, run the following from command-line terminal:
$ npm install -g ios-deploy
Installing the Cordova CLI
- The Cordova command-line tool is distributed as an npm package.
To install the
cordovacommand-line tool, follow these steps:Download and install Node.js. On installation you should be able to invoke
nodeandnpmon your command line.(Optional) Download and install a git client, if you don't already have one. Following installation, you should be able to invoke
giton your command line. The CLI uses it to download assets when they are referenced using a url to a git repo.Install the
cordovamodule usingnpmutility of Node.js. Thecordovamodule will automatically be downloaded by thenpmutility:
$ npm install -g cordova
Deploy the App
Create the App
- Go to the directory where you maintain your source code, and create a cordova project:
$ cordova create hello com.example.hello HelloWorld
- This creates the required directory structure for your cordova app. By default, the
cordova createscript generates a skeletal web-based application whose home page is the project'swww/index.htmlfile (see in Sample code).
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 'ios' platform and ensure they get saved to
config.xmlandpackage.json:
$ cordova platform add ios
- To check your current set of platforms:
$ cordova platform ls
- To check if you satisfy requirements for building the platform:
$ cordova requirements
- Run the following command to prepare the project for ios platforms (if you change code in HTML file or Cordova APIs JS file):
$ cordova prepare ios
- Run the following command to build the project for ios platforms:
$ cordova build ios
- Run the following command to run the project for ios platforms on emulate or real device:
$ cordova run ios