Testing and Debugging in iOS Simulator
iOS Simulator is a great tool for rapid prototyping and development before testing your app on a device. iOS Simulator also has features that can assist you in testing and debugging both iOS apps and web apps. By understanding the tools that iOS Simulator offers, you can more efficiently develop your app.
Limitations of Testing in iOS Simulator
Even though iOS Simulator is a useful tool, never make it the only way you test an app. Because iOS Simulator is an app running on a Mac, it has access to the computer’s memory, which is much greater than the memory found on a device. As a result of the increased memory, iOS Simulator is not an accurate test of an app’s memory usage. For this same reason, you should always test the performance of your app’s user interface (UI) on a device. In iOS Simulator, your app’s UI may appear to run both faster and smoother than on a device.
Also keep in mind that some UI elements can be easier to interact with in iOS Simulator using a mouse than when trying to interact with the app via touch on a device.
Finally, there are some hardware and API limitations of iOS Simulator. These limitations may affect your app when testing in iOS Simulator.
While most of the functionality of iOS devices can be simulated in iOS Simulator, there are some hardware features that must be tested directly on a device. The hardware features that cannot be simulated are:
To test your app on a device, you must be a member of the iOS Developer Program. To learn more about enrolling in the iOS Developer Program, see “Enrolling in an Apple Developer Program and Accessing Its Tools”.`
Within iOS Simulator, there are some limitations to the APIs and features, including:
Apple Push Services
Privacy alerts for access to Photos, Contacts, Calendar, and Reminders
iCloud document syncing and key-value storage support
Unsupported frameworks include:
In UIKit, the
iOS Version Limitations
iOS Simulator app does not have complete backward compatibility. How far back you can go is dependent on what version of OS X your computer is running. Computers running Mac OS X v10.8 support legacy simulators back to iOS 5.0, and computers running Mac OS X v10.7 can support legacy simulators back to iOS 3.4.
To use iOS Simulator for iOS 6.0, you must be running Xcode 4.5.
Testing for the iPad mini
Although an iPad mini isn’t an option for a simulated device in iOS Simulator, you can still test apps for the iPad mini in the simulator. To do this, run your app on the simulated iPad without Retina display.
Testing App Accessibility
Use the Accessibility Inspector to test the accessibility of your app. The Accessibility Inspector displays accessibility information about each accessible element in an app. In Figure 3-1 you can see what the Accessibility Inspector looks like as it runs in iOS Simulator.
When iOS Simulator is running, click the Home button to reveal the Home screen.
Go to General > Accessibility.
Slide the Accessibility Inspector switch to On.
Turning on the Accessibility Inspector in iOS Simulator alters the behavior of the simulator. After the Accessibility Inspector is on, clicking an element moves the focus of the inspector to that element instead of activating it. To activate an element, you must double-click it. Additionally, swiping and dragging gestures are unsupported while the Accessibility Inspector is running. To perform these gestures, you must first disable the Accessibility Inspector. To disable and re-enable the Accessibility Inspector, click the close control in the upper-left corner of the inspector panel (the close control looks like a circle with an “X” in it).
For more information on using the Accessibility Inspector and testing the accessibility of your app, see Verifying App Accessibility on iOS.
Testing App Localization
If you have created an app with multiple localizations, you can test them in iOS Simulator by changing the Internationalization settings.
Build and run your app in iOS Simulator.
Select the simulation environment whose settings you want to change by choosing Hardware > Version > iOS version.
Click the Home button to reveal the Home screen, and click Settings.
Go to General > International > Language.
Select the language, and click Done.
For more information on localizing your app, see Internationalization Programming Topics.
Testing Web Apps
If you are building a web app and want to test its usability on an iOS device, let iOS Simulator assist you.
Select the simulator environment you would like to test in by choosing Hardware > Version > iOS version.
Open Safari from the Home screen of iOS Simulator.
Navigate to the location of your web app in the browser.
For more information on creating web apps for iOS, see Getting Started with iOS Web Apps.
Testing Bluetooth Support
You can use iOS Simulator to test Bluetooth-enabled apps without the use of a Bluetooth LE–capable device. Here’s what you need to proceed:
A Mac running OS X 10.8.3 or later
Xcode 4.2.1 with iOS 5.0 SDK or greater
A Bluetooth LE USB Adapter
If your Mac has Bluetooth 4.0 built in, you still need to have a Bluetooth LE USB adapter to test your Bluetooth app.
Set the NVRAM setting.
Open a Terminal window and type the following NVRAM command:
user$ sudo nvram bluetoothHostControllerSwitchBehavior="never"
A system restart is not required after changing this setting.
Attach the Bluetooth LE USB adapter to your Mac.
The Bluetooth LE USB adapter must be connected after issuing the NVRAM command.
Verify the NVRAM setting using the System Information utility.
You’ll find System Information in the Utilities folder within your Applications folder. Select Bluetooth within the Hardware menu and verify that the Vendor ID is
If the system Bluetooth controller is matched to the Bluetooth LE USB adapter, then iOS Simulator cannot use the external Bluetooth controller for Bluetooth LE services. In this case, you might see a System Information Bluetooth panel like this:
Here, the Bluetooth driver is matched to the Cambridge Silicon Radio (CSR) Bluetooth LE USB adapter. If this is the case, remove the adapter and return to step 1.
Enable Bluetooth in iOS Simulator.
In Xcode, launch your app in iOS Simulator. When iOS Simulator opens, close the app to return to the Home screen, and open the Settings app. Select the General tab and then verify that Bluetooth is on.
Relaunch the iOS app in the simulator. The iOS Core Bluetooth app should connect and communicate with Bluetooth LE devices, as it does when run on an iOS device with Bluetooth LE support.
Using the Debugging Tools in iOS Simulator
Access the debugging tools in iOS Simulator through the Debug menu, as shown in Table 3-1.
Toggle Slow Animations
Slows down the animation taking place within the app. Use to identify any problems in the animation. Toggle Slow Animations can also be activated by pressing the Shift key three times.
Color Blended Layers
Shows blended view layers. Multiple view layers that are drawn on top of each other with blending enabled are highlighted in red. Reduce the amount of red in your app when this option is selected to dramatically improve your app’s performance. Blended view layers are often the cause of slow table scrolling.
Color Copied Images
Shows images that are copied by Core Animation in blue.
Color Misaligned Images
Places a yellow overlay over images whose source pixels are not aligned to the destination pixels.
Color Off Screen Rendered
Places a magenta overlay on content that is rendered offscreen.
Allows you to set the Core Location to be used by your app. Choose from the different location settings:
Viewing Crash Logs
If your app experiences a problem that causes it to crash, a crash log can help you determine what problem occurred. You open the crash log using Console.
© 2013 Apple Inc. All Rights Reserved. (Last updated: 2013-04-23)