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, always test the performance of your app’s user interface on a device. In iOS Simulator, your app’s user interface may appear to run both faster and smoother than on a device.
Also keep in mind that some user interface 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.
Though most of the functionality of iOS devices can be simulated in iOS Simulator, some hardware features must be tested directly on a device. The hardware features that cannot be simulated are:
Audio and Video Input
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 Managing Accounts in App Distribution Guide.
OpenGL ES Limitations
iOS Simulator includes complete implementations of OpenGL ES 1.1, 2.0, and 3.0 that you can use to start developing your app. The capabilities of iOS Simulator are similar to those of the A7 GPU; for more information on the iOS hardware, see iOS Device Compatibility Reference. iOS Simulator differs from the hardware processor in a few ways:
iOS Simulator does not use a tile-based deferred renderer.
iOS Simulator does not provide a pixel-accurate match to the graphics hardware.
Rendering performance of OpenGL ES in iOS Simulator has no relation to the performance of OpenGL ES on an actual device.
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 does not have complete backward compatibility. In addition to supporting iOS 7.1, iOS Simulator supports iOS versions 7.0 and 6.1.
To use iOS Simulator for iOS 7.0 and later, you must be running Xcode 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 for 64-bit Compatibility
iOS Simulator includes the ability to simulate 64-bit hardware. Choose one of the simulator targets that includes 64-bit in the name; your app is automatically compiled using the 64-bit data types described in 64-Bit Transition Guide for Cocoa Touch. Use Simulator to test any changes in your code that were necessary to support the new data sizes and alignments.
Some changes in the 64-bit ABI are not testable in Simulator. For example, any changes related to function or method calls can only be discovered when running on actual iOS hardware. So, as with developing any other iOS app, Simulator is best used only for the initial work to develop and test your app.
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. Figure 3-1 shows what the Accessibility Inspector looks like as it runs in iOS Simulator.
To start the Accessibility Inspector
When iOS Simulator is running, choose Hardware > Home 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 reenable 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. For how to set the language and region on iOS, read Reviewing Language and Region Settings on iOS Devices in Internationalization and Localization Guide. For more information on localizing your app, read Internationalization and Localization Guide.
Testing Web Apps
If you are building a web app and want to test its usability on an iOS device, iOS Simulator can assist you.
To test a web app in iOS Simulator
Select the simulator environment you would like to test in by choosing a device from the Hardware > Devices menu.
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.
If you are building an app that uses iCloud, you can test iCloud syncing from within iOS Simulator before testing on physical devices. This can also assist you in testing iCloud syncing across many devices if you have a limited number of devices to test on.
To simulate iCloud syncing, you must first sign in to iOS Simulator using an Apple ID. It is strongly encouraged that you create and use a separate Apple ID specifically for testing iCloud in iOS Simulator.
To sign in to iOS Simulator with your Apple ID
Launch iOS Simulator with a simulated device running iOS 7.1 or later.
From the Home screen, open Settings and select iCloud.
Enter your Apple ID and Password, and click Sign In.
After signing in with your Apple ID, you can then test your iCloud syncing. To test to see whether your app is syncing properly with iCloud, choose Debug > Trigger iCloud sync.
Testing Background Fetching
If you are building an app that receives frequent content updates and you have enabled background fetching, you can test the background-fetch capability using Xcode and iOS Simulator. To simulate a background fetch, launch your app in iOS Simulator and then go to Xcode and choose Debug > Simulate Background Fetch.
You can also configure a scheme to control how Xcode launches your app. To enable your app to be launched directly into a suspended state, choose Product > Scheme > Edit Scheme, and select the Background Fetch checkbox.
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 in Frontmost App
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, while multiple view layers that are drawn without blending are highlighted in green. 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
Places a blue overlay over images that are copied by Core Animation in blue.
Color Misaligned Images
Places a magenta overlay over images whose bounds are not aligned to the destination pixels. If there is not a magenta overlay, places yellow overlay over images drawn with a scale factor.
Color Off Screen Rendered
Places a yellow 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.
To view a crash log
Open Console by going to
Applications/Utilities/Consolein the Finder.
Look for the line in Console that reads “Saved Crash Report for.”
Expand this item using the arrow at the left.
Click Open Report.