Читать книгу Swift iOS 24-Hour Trainer - Mishra Abhishek - Страница 9

Section I
Hello iOS!
Lesson 2
A Tour of Xcode and the iOS Simulator
Features of the iOS Simulator

Оглавление

When you run an application from the Xcode IDE, unless you have selected a device in the Scheme/Target multi-selector, your application will be launched in the iOS Simulator. Figure 2.22 shows the iPhone 5S simulator. You can use the iOS Simulator to simulate different device and SDK versions. To switch devices use the Hardware Device menu.


Figure 2.22


You can rotate the simulator by using the Rotate Left or Rotate Right menu items from the Hardware menu. The iOS Simulator allows you to simulate a variety of one and two-finger multi-touch gestures. Single-finger gestures such as taps and swipes can be performed by clicking and dragging with the mouse. The only two-finger gesture that you can simulate is the pinch. To do so, hold down the Option key on your keyboard while clicking and dragging with the mouse in the simulator window. Shake gestures can be performed by using the Hardware Shake Gesture menu item.

If you are developing an app that requires location data, you can use the iOS Simulator to simulate a test location while you are running your application within the simulator. Select Debug Location Custom Location to specify a latitude and longitude pair (Figure 2.23). Creating location-based applications is covered in Lessons 29 and 30.


Figure 2.23


The simulator can also simulate changing locations. This is particularly useful if your app is designed to be used while on the move. From the Debug Location menu, you can select from a list of prerecorded location sets. The simulator will then periodically cycle between the locations in the selected set. The sets are:

• Apple Stores

• City Bicycle Ride

• City Run

• Freeway Drive

Installing and Uninstalling Applications

To install an application to the iOS Simulator, you need to open its corresponding .xcodeproj file in Xcode and click the Run button in the Xcode toolbar.

You cannot delete the default iOS Simulator applications (such as Photos, Settings, Game Center, Safari, and so on). To uninstall (delete) one of your applications from the iOS Simulator, click and hold the mouse button down on the icon of the app until all the icons start to wiggle. Once they start to wiggle, you will notice an X button on the top-left corner of each icon.

Release the mouse button if you are still holding it down; the icons will still continue to wiggle. Click the X button on the icon of the app you want to delete. An alert window will appear asking you to confirm this action.

Limitations of the iOS Simulator

As good as the iOS Simulator may be, it has its limitations. For starters, you cannot make calls, send or receive text messages, or install apps from the App Store.

The performance of the iOS Simulator depends on the speed of your Mac, and in certain cases your application may appear to execute much faster on your Mac (in the iOS Simulator) than it does on the real device.

Accelerometer, camera, and microphone functions are not supported in the iOS Simulator. If you are developing OpenGL/ES-based applications, you should keep in mind that several OpenGL/ES functions are not supported on the iOS Simulator.

The iOS Simulator is a useful tool to test your apps but it is definitely not a replacement for testing on a real device.

Swift iOS 24-Hour Trainer

Подняться наверх