官术网_书友最值得收藏!

The iOS setup

In order to be able to run the application being developed in an iOS simulator or on an iOS device connected to our computer, we need the following components:

  • OS: Mac OS X
  • IDE: Xcode (6.0 and newer)
  • iOS SDK

The only disappointment when developing for iOS with the ability to debug on your computer is a limitation of the operating system by Apple. Unfortunately, it must only be Mac OS X operating system that does this. If you do not want the ability to run applications on your computer, you can simply use the service PhoneGap Build. However, as we try to better understand the features of PhoneGap, we should look deeper into platform-specific aspects.

We can test many of the Cordova features using the iOS emulator installed with the iOS SDK and Xcode, but we need an actual device to fully test all of the app's device features before submitting it to the App Store. To install apps onto a device, we should be a member of Apple's iOS Developer Program, which costs $ 99 per year. Next, we will describe how to run our application in an iOS emulator, which does not require the acquisition of the program.

So, let's say, we already have Mac OS X installed. The next thing we need to do is install Xcode. It is very simple. Follow these steps:

  1. By keyword "Xcode", find the application in the App Store and press the Install App button. Once Xcode is installed, several command-line tools need to be enabled for Cordova to run.
  2. From the Xcode menu, select Preferences.
  3. Then, click on the Downloads tab.
  4. From the Components panel, press the Install button next to the command-line tools listing.
  5. On the same window, you can install other components, such as several versions of an iOS simulator.

Now, with the help of the Cordova CLI, we can add our future version of iOS applications:

$ cd travelly
$ cordova platform add ios
Creating ios project...

Now, in the platform folder, the ios subfolder appeared, and in the plugins folder, the ios.json file appeared. Let's open travelly/platforms/ios/Travelly.xcodeproj in Xcode.

The Xcode window should look as follows:

The iOS setup

Running the application in the iOS emulator

Now, let's run our application in the iOS emulator using the following steps:

  1. Select the intended device from the toolbar's Scheme menu, such as the iPhone 6, as highlighted here:
    Running the application in the iOS emulator
  2. Press the Run button that appears in the same toolbar to the left of Scheme. This button builds, deploys, and runs the application in the emulator. A separate emulator application opens to display the app:
    Running the application in the iOS emulator

A similar procedure can be done with the help of the Cordova CLI:

$ cordova build ios

This generates ios platform-specific code within the project's platforms subdirectory.

The cordova build command is a shorthand for the following command:

 $ cordova prepare ios
 $ cordova compile ios

To run our application in the iOS emulator, it is enough to execute the following command:

$ cordova emulate ios

We will see the same application in the emulator that we saw when run from Xcode.

主站蜘蛛池模板: 乾安县| 柯坪县| 襄垣县| 天祝| 河西区| 海城市| 孟州市| 东城区| 老河口市| 象山县| 安丘市| 大连市| 武陟县| 栾城县| 台前县| 南投县| 恩施市| 承德市| 略阳县| 闸北区| 海口市| 武宁县| 赤城县| 巨鹿县| 红原县| 平遥县| 华容县| 华坪县| 鄱阳县| 陕西省| 新干县| 新津县| 玉龙| 横峰县| 克拉玛依市| 仙游县| 凤山市| 南丹县| 新乡市| 和田市| 榆中县|