iOS Reference Library Apple Developer
Search

Using iPhone Simulator

The iOS simulation environment lets you build and run your iPhone or iPad application on your computer. You use the simulation environment to:

A major part of the iOS simulation environment is the iPhone Simulator application. This application presents the iPhone or iPad user interface in a window on your computer. The application provides several ways of interacting with it using your keyboard and mouse to simulate taps and device rotation, among other gestures.

Important: iOS 4.0 uses the same Objective-C runtime as Mac OS X v10.6. iOS 3.2 and earlier use the Mac OS X v10.5 Objective-C runtime. Because of this change, binaries generated with an iPhone SDK distribution earlier than 4.0 do not run in the simulator that‚Äôs part of the iPhone SDK 4.0 and later distributions. After moving from iPhone SDK 3.2 and earlier distributions to a 4.0 or later distribution, you must rebuild your iPhone Simulator binaries to run them in the simulator. If you use licensed static libraries in your application, you must obtain versions of them generated with an iPhone SDK 4.0 or later distribution. For more information about the Objective-C runtime, see Objective-C Runtime Reference.

The following sections describe the ways in which you use your computer’s input devices to simulate the interaction between users and their devices. They also show how to uninstall applications from the simulator and how to reset the contents of the simulator.

Setting the Simulation-Environment Device Family and iOS Version

iPhone Simulator can simulate two device families (iPhone and iPad) and more than one iOS release.

To specify the device family you want to simulate, choose Hardware > Device, and choose the device family.

To set the iOS release used in the simulation environment, choose Hardware > Version, and choose the version you want to test on.

Manipulating the Hardware

iPhone Simulator lets you simulate most of the actions a user performs on her device. When you’re running your application in iPhone Simulator, you can carry out these hardware interactions through the Hardware menu:

Performing Gestures

Table 4-1 lists gestures you can perform on the simulator (see iPhone Human Interface Guidelines for gesture information).

Table 4-1  Performing gestures in iPhone Simulator

Gesture

Desktop action

Tap

Click.

Touch and hold

Hold down the mouse button.

Double tap

Double click.

Swipe

1. Place the pointer at the start position.

2. Hold the mouse button.

3. Move the pointer in the swipe direction and release the mouse button.

Flick

1. Place the pointer at the start position.

2. Hold the mouse button.

3. Move the pointer quickly in the flick direction and release the mouse button.

Drag

1. Place the pointer at the start position.

2. Hold down the mouse button.

3. Move the pointer in the drag direction.

Pinch

1. Hold down the Option key.

2. Move the circles that represent finger touches to the start position.

3. Hold down the mouse button and move the circles to the end position.

Installing Applications

Xcode installs applications in iPhone Simulator automatically when you build your application using the iPhone Simulator SDK. See “Running Applications” for details.

In iPhone Simulator, you can install only applications that you build using the iPhone Simulator SDK. You cannot install applications from the App Store in the simulator.

Uninstalling Applications

To uninstall applications you have installed on the simulator use the same method used to uninstall applications from devices:

  1. Place the pointer over the icon of the application you want to uninstall and hold down the mouse button until the icon starts to wiggle.

  2. Click the icon’s close button.

  3. Click the Home button to stop the icon wiggling.

Resetting Content and Settings

To set the user content and settings of the simulator to their factory state and remove the applications you have installed, choose iPhone Simulator > Reset Content and Settings.

Core Location Functionality

The relocation reported by the CoreLocation framework in the simulator is fixed at the following coordinates (accuracy 100 meters), which correspond to 1 Infinite Loop, Cupertino, CA 95014.

Viewing iPhone Simulator Console Logs

To learn how to view your application’s console logs when it runs in iPhone Simulator, see “Viewing Console and Crash Logs.”

iPhone Simulator File System on Host

iPhone Simulator stores the User domain of the iOS file system in your home directory at:

~/Library/Application Support/iPhone Simulator/User

The User domain comprises all user data iOS stores including third-party application binaries, system databases (such as the Address Book and Calendar databases), application preferences, and so on. This location is also known as <iOSUserDomain>.

iPhone Simulator stores system application preferences files in <iOSUserDomain>/Library/Preferences.

Third-party–application preferences files are stored in <iOSUserDomain>/Applications/<app_UUID>Library/Preferences.

Hardware Simulation Support

iPhone Simulator doesn’t simulate accelerometer or camera hardware.




Last updated: 2010-07-02

Did this document help you? Yes It's good, but... Not helpful...