The iPhone simulation environment lets you build and run your iPhone application on your computer. You use the simulator environment to:
Find and fix major problems in your application during design and early testing.
Learn about the Xcode development experience and the iPhone development environment before becoming a member of the iPhone Developer Program.
Lay out and test your application’s user interface.
Measure your application’s memory usage before carrying out detailed performance analysis on iPhone OS–based devices.
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.
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.
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:
Rotate Left. Rotates the simulator to the left.
Rotate Right. Rotates the simulator the right.
Shake. Shakes the simulator.
Home. Takes the simulator to the Home screen.
Lock. Locks the simulator.
Simulate Memory Warning. Sends the frontmost application low-memory warnings. For information on how to handle low-memory situations, see “Observing Low-Memory Warnings” in iPhone Application Programming Guide.
Toggle In-Call Status Bar. Toggles the status bar between its normal state and its in-call state. The status bar is taller in its in-call state than in its normal state. This command shows you how your application’s user interface looks when the user launches your application while a phone call is in progress.
Table 4-1 lists gestures you can perform on the simulator (see iPhone Human Interface Guidelines for gesture information).
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. |
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.
To uninstall applications you have installed on the simulator use the same method used to uninstall applications from devices:
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.
Click the icon’s close button.
Click the Home button to stop the icon wiggling.
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.
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.
Latitude: 37.3317 North
Longitude: 122.0307 West
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 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.
To learn about the frameworks available in iPhone Simulator, see “iPhone Simulator Frameworks and Libraries.”
Last updated: 2009-08-06