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.

AreaWhat the 2018 guide says
Hardware not simulatedMotion (accelerometer and gyroscope), audio and video input (camera and microphone), proximity sensor, barometer, ambient light sensor
LocationSupported through Debug → Location, with presets such as None, Custom Location, Apple, City Bicycle Ride, City Run and Freeway Drive
PerformanceNot accurate: Mac resources are typically faster than a device's, and UI rendering is faster and smoother
InputThe interface is easier with a mouse than with touch
APIsLacked several APIs in 2018, including Apple Push Notifications and privacy alerts for Photos, Contacts, Calendar and Reminders
Some of That List Is Out of Date
A more recent tutorial says that from Xcode 14, simulators running on macOS 13 on Apple silicon or T2 Macs can receive remote push notifications, but only for debug builds using the Apple Push Notification Service sandbox. That contradicts the 2018 guide's statement about push notifications. A forum thread I found says the camera is unsupported in the Simulator, which matches the 2018 guide, but I could not confirm the current position from Apple. When a step depends on a hardware feature, check the current documentation for your Xcode version, and if in doubt, test on a device.
Connection to Chapter 5
The guide's warning that the Simulator is not accurate for performance is the reason Chapter 5 recommends profiling a Release build on a real device where you can. The Mac's speed hides problems a phone will show. iOS Development — Architecture & Data 8 covers device capabilities such as the camera and location, which are the areas where the Simulator differs most.

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 lifetimeProvisioning profiles that let an app install on a device expire after 7 days
DevicesUp to 3 devices
Apps per deviceUp to 3
App IDsUp to 10, expiring after 7 days
RenewingRebuild and run from Xcode to renew after expiry
Third-Party Figures
These numbers come from a blog post titled as covering new limitations on free accounts and from forum discussions, not from Apple's current documentation, and Apple has changed them before. Treat them as a guide to the kind of restriction, not as the current limits. Apple's account help pages describe the free and paid memberships, and those are the source to check.

Which to Use When

  1. Day-to-day layout and logic: the Simulator and SwiftUI Previews.
  2. Camera, motion, sensors: a real device.
  3. Performance and memory: a real device, in a Release build (Chapter 5).
  4. Push notifications: a recent Simulator may work for debug builds against the sandbox, but check your Xcode version.
  5. Anything you plan to ship: at least one final run on a real device.

Hands-On Exercises

Exercise 1

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 solution
Exercise 2

You 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 solution
Exercise 3

A 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 solution

Chapter 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