The iOS simulation environment lets you build and run your iPhone or iPad application on your computer. You use the simulation environment to:
Find and fix major problems in your application during design and early testing.
Learn about the Xcode development experience and the iOS 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 iOS-based devices.
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.
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.
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:
Rotate Left. Rotates the simulator to the left.
Rotate Right. Rotates the simulator the right.
Shake Gesture. 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 iOS 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 how your application’s user interface looks when the user launches your application while a phone call is in progress.
Simulate Hardware Keyboard. Toggles the software keyboard on iPad simulation. Turn off the software keyboard to simulate using a keyboard dock or wireless keyboard with an iPad device.
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
To learn how to view your application’s console logs when it runs in iPhone Simulator, see “Viewing Console and Crash Logs.”
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
.
iPhone Simulator doesn’t simulate accelerometer or camera hardware.
Last updated: 2010-07-02