iPhone OS Reference Library Apple Developer Connection spyglass button

Using iPhone Simulator

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

A major part of the iPhone simulation environment is the iPhone Simulator application. This application presents the iPhone 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.

iPhone OS supports the Objective-C runtime introduced in Mac OS X v10.5 except for access to Objective-C class metadata. This means that, if your application accesses Objective-C class metadata, it may not run on iPhone Simulator. See Objective-C Runtime Reference for more information.

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 iPhone OS Version

iPhone Simulator can simulate more than one iPhone OS release. To set the iPhone OS 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 their 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.

Accelerometer Access

Although you can access your computer’s accelerometer (if it has one) through the UIKit framework, its readings differ from the accelerometer readings on a device. This discrepancy stems largely from the different positioning of the screen in relation to the rest of the hardware between computers and iPhone OS–based devices.

iPhone Simulator File System on Host

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

~/Library/Application Support/iPhone Simulator/User

The User domain comprises all user data iPhone OS 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 <iPhoneUserDomain>.

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

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

Further Exploration

To learn about the frameworks available in iPhone Simulator, see “iPhone Simulator Frameworks and Libraries.”



Last updated: 2009-08-06

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