Getting Started in iOS Simulator
The iOS Simulator app, available within Xcode, presents the iPhone or iPad user interface in a window on your Mac computer. You interact with iOS Simulator by using the keyboard and the mouse to emulate taps, device rotation, and other user actions.
This chapter explains the basic capabilities of iOS Simulator. You will use an iPhone app to gain some hands-on experience with iOS Simulator, allowing you to become familiar with the tool. If you do not have an iPhone app to use, you can use the HelloWorld app. For more detailed information on interacting iOS Simulator and using it to test and debug your apps, refer to the later chapters in this book.
Access iOS Simulator from Xcode
There are two different ways to access iOS Simulator through Xcode. The first way is to run your app in iOS Simulator, and the second way is to launch iOS Simulator without running an app.
Running Your App in iOS Simulator
When testing an app in iOS Simulator, it is easiest to launch and run your app in iOS Simulator directly from your Xcode project. To run your app in iOS Simulator, choose iPhone 6.0 Simulator from the Xcode scheme pop-up menu, and click Run. Xcode builds your project and then launches the most recent version of your app running in iOS Simulator on your Mac’s screen, as shown in Figure 1-1.

Launching iOS Simulator Without Running an App
At times, you may want to launch iOS Simulator without running an app. This approach is helpful if you want to test how your app launches from the Home screen of a device or if you want to test a web app in Safari in iOS Simulator.
Launch Xcode.
Do one of the following:
Choose Xcode > Open Developer Tool > iOS Simulator.
Control-click the Xcode icon in the Dock, and choose Open Developer Tool > iOS Simulator from the shortcut menu.
iOS Simulator opens and displays the Home screen of whichever simulated device was last used.
View the Installed Apps
From the Home screen, you have access to all of the apps that are installed in the iOS 6.0 simulation environment. There are two ways to access the Home screen in iOS Simulator from your app:
Click the Home button.
Choose Hardware > Home.
Much like the Home screen on an iOS device, the simulator’s Home screen has multiple pages. After clicking the Home button (or accessing the Home screen through the Hardware menu), you arrive at the second page of the Home screen. To get to the first page, where all of the preinstalled apps are found, swipe to the first Home screen by dragging to the right on the simulator screen.
On the Home screen, you see all of the apps that have been preloaded into iOS Simulator, as shown in Figure 1-2.

The apps you see on the Home screen are specific to the simulated iPhone in the iOS 6.0 simulation environment. Because the Maps app is available only on iOS 6.0 and Passbook is available only in iOS 6.0 for the iPhone, these apps won’t appear if you switch to a legacy simulator or to simulating an unsupported device type.
Use the installed apps to test your app’s interaction with them. For example, if you are testing a game, you can use iOS Simulator to ensure that the game is using Game Center correctly.
Use Safari to Test Web Apps
From the Home screen you can access Safari within iOS Simulator. Use Safari to test your iOS web apps directly on your Mac.
From the Home screen, click Safari.
In the address field in Safari, type
apple.comand press the Return key.
If your Mac is connected to the Internet, Safari displays the Apple website. See Figure 1-3.

Use Maps to Simulate Location Awareness
iOS Simulator provides tools to assist you in debugging your iOS app. One of the many features you can debug in iOS Simulator is location awareness within your app. Here’s an example of how to simulate a different location, which can be seen in the Maps app:
From the Home screen, click Maps.
Choose Debug > Location > Custom Location.
In the window that appears, type the number
40.75in the latitude field, and the number-73.75in the longitude field.Click OK.
Click the Current Location button in the bottom-left corner of the simulated device screen.
After completing this task, notice that the blue dot representing your location is in New York, NY, near the Long Island Expressway, as shown in Figure 1-4.

Change the Simulated Hardware Device
iOS Simulator provides the ability to simulate five devices:
iPhone
iPhone (Retina 3.5-inch)
iPhone (Retina 4-inch)
iPad
iPad (Retina)
To change the hardware device you are simulating to an iPad, choose Hardware > Device > iPad. The iOS Simulator display you saw in Figure 1-2 changes from an iPhone to an iPad, as shown in Figure 1-5.

Because the Passbook app is available only on iPhone, its icon, which was visible in Figure 1-2 for iPhone, is not visible in Figure 1-5 for iPad.
If you are using a computer whose screen is not large enough to display an entire simulated iPad, only the screen of the iPad is displayed, not the device border around it. If this is the case for you, you must access the Home screen though the Hardware menu.
If you are testing an iPad app, you can test only on a simulated iPad. If you are testing an iPhone or a universal app, you can test on either a simulated iPhone or a simulated iPad.
Change the iOS Version
In addition to simulating various hardware devices, you can also change the simulated software version. Each simulated software version is considered its own simulation environment, and each simulation environment has its own settings and applications. To change the simulator to run the iOS 5.1 version, choose Hardware > Version > 5.1. If iOS 5.1 is not listed as an option in the menu, you need to download the legacy simulator in Xcode and then relaunch iOS Simulator.
In Xcode, choose Xcode > Preferences.
In the Preferences window, click Downloads.
In Components, find the legacy simulator version you want to add, and click the Install button.
After you change the iOS version you are simulating, iOS Simulator reopens. Because the Maps app is new to iOS 6.0, notice that Maps is no longer available on the Home screen in the iOS 5.1 simulation environment.
Alter the Settings in iOS Simulator
You can alter the settings within iOS Simulator to help test your app. To open the Settings app in iOS Simulator, go to the Home screen in iOS Simulator and click Settings. In Figure 1-6 you see the Settings app as it appears when launched in the iOS 5.1 simulation environment.

The iOS Simulator settings differ from the settings found on a hardware device. iOS Simulator is designed for testing your apps, whereas a hardware device is designed for use. Because iOS Simulator is designed for testing apps, its settings are naturally focused on testing too. For example, in iOS Simulator the Accessibility menu provides the ability to turn on the Accessibility Inspector, and the Accessibility menu on a device allows you to turn on and off different accessibility features.
Through the settings, you can test both accessibility and localization of your app. See “Testing and Debugging in iOS Simulator” for information on how to manipulate your settings for the various types of testing you are interested in.
Rotate the Device
You can use iOS Simulator to manipulate the simulated device much as you do a physical device.
To rotate your simulated device, choose Hardware > Rotate Left. When you rotate your simulated device, you see that Settings rotates (see Figure 1-7), just as it would on a hardware device.

Test in iOS Simulator and on a Device
iOS Simulator is designed to assist you in designing, rapidly prototyping, and testing your app, but it should never serve as your sole platform for testing. One reason is that not all apps are available in the simulator. For example, the Camera app is available only on hardware devices and cannot be replicated in the simulator.
In addition, not all bugs and performance problems can be caught through testing in iOS Simulator alone. You’ll learn more about performance limitations in “Testing and Debugging in iOS Simulator.” You can also find more information on testing your app on a device in App Distribution Guide.
Quit iOS Simulator
iOS Simulator continues running until you quit it. Even if you quit Xcode, iOS Simulator continues to run because it is a separate app. To quit iOS Simulator, choose iOS Simulator > Quit iOS Simulator. If Xcode is running, Xcode remains open.
© 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-04-23)