The Simulator & Running on Real Devices
Xcode: The IDE Itself
Chapter 6 ยท The Simulator & Running on Real Devices
Every chapter so far has assumed you can run your app somewhere. This chapter covers the two places to run it from Xcode: the Simulator on your Mac and a physical device. It sets out what the Simulator can and cannot do, why you still need a real device, and what running on one involves. Much of the detail here is dated or comes from third-party sources, so the chapter pays attention to how old each claim is.
What the Simulator Is For
The Simulator lets you run your app on simulated Apple devices and OS versions without owning the hardware. Apple's developer page lists it for rapid prototyping across devices and OS versions, with advanced debugging. It is the fastest way to see a change, and it works with Chapter 3's SwiftUI Previews and Chapter 4's debugger.
What It Cannot Do, and a Dated Source
The most detailed list I found is from Apple's own Simulator guide, which is archived. It was retired and deprecated in Xcode 9 and was last updated on 15 February 2018. That makes it useful as a description of the kinds of limits a simulator has, and unreliable for the current list.
| Area | What the 2018 guide says |
|---|---|
| Hardware not simulated | Motion (accelerometer and gyroscope), audio and video input (camera and microphone), proximity sensor, barometer, ambient light sensor |
| Location | Supported through Debug → Location, with presets such as None, Custom Location, Apple, City Bicycle Ride, City Run and Freeway Drive |
| Performance | Not accurate: Mac resources are typically faster than a device's, and UI rendering is faster and smoother |
| Input | The interface is easier with a mouse than with touch |
| APIs | Lacked several APIs in 2018, including Apple Push Notifications and privacy alerts for Photos, Contacts, Calendar and Reminders |
Running on a Real Device
Running on a device means the app has to be code signed so the device will accept it. iOS Development — Production & Publishing 4 covers certificates and provisioning profiles in depth, including the split between development and distribution certificates, so this chapter keeps to what changes for running on your own device.
A Free Apple ID
You can run on a device with a free Apple ID, with restrictions. The sources I found, mostly a blog post and forum threads, report these limits.
| Limit (free account) | Reported figure |
|---|---|
| Profile lifetime | Provisioning profiles that let an app install on a device expire after 7 days |
| Devices | Up to 3 devices |
| Apps per device | Up to 3 |
| App IDs | Up to 10, expiring after 7 days |
| Renewing | Rebuild and run from Xcode to renew after expiry |
Which to Use When
- Day-to-day layout and logic: the Simulator and SwiftUI Previews.
- Camera, motion, sensors: a real device.
- Performance and memory: a real device, in a Release build (Chapter 5).
- Push notifications: a recent Simulator may work for debug builds against the sandbox, but check your Xcode version.
- Anything you plan to ship: at least one final run on a real device.
Hands-On Exercises
Using the 2018 guide, list four things the Simulator did not simulate and explain why the guide's date should make you cautious about the list.
๐ View solutionYou have a photo-capture feature, a map with location, and a list screen. For each, say where you would test it first and where you would test it last, and why.
๐ View solutionA colleague says "you can only run iOS apps on a real iPhone if you pay Apple $99 a year." Using this chapter, say what the sources support, what they do not, and where you would check.
๐ View solutionChapter 6 Quick Reference
- Simulator: runs on simulated Apple devices and OS versions; fast, but not accurate for performance
- 2018 archived guide: camera, microphone, motion sensors, proximity, barometer and ambient light were not simulated; location is, via Debug → Location
- Since then: a later tutorial reports remote push notifications work in newer simulators for debug builds against the sandbox
- Free Apple ID: reported 7-day profile expiry, 3 devices, 3 apps per device, 10 App IDs (third-party figures)
- Signing depth: see iOS Development — Production & Publishing 4
- Unverified: current Simulator limits, the current free-account limits, and Apple's own page on running on a device