Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

How to run and debug apps on the simulator?

To run an iOS app on the Simulator, open your project in Xcode, pick a Simulator device from the run-destination menu, and press Cmd+R. Xcode builds the app, boots the Simulator, installs the build, and launches it. To debug it, set breakpoints in the gutter and run again. When execution pauses on a breakpoint, the Debug area opens with the LLDB console and variables view so you can inspect state, step through code, and evaluate expressions. You can also drive everything from the terminal with the xcrun simctl command line.

What You Need Before You Start

The iOS Simulator ships only with Xcode on macOS, so the prerequisites are a Mac, a current version of Xcode from the Mac App Store, and at least one installed simulator runtime (for example, iOS 18 on an iPhone 16 Pro). If your run-destination menu has no devices listed, you first need to add a runtime. The steps for that are covered in How to Install iOS Simulators?. Once Xcode and at least one simulator are in place, you are ready to build and run.

Run an App on the iOS Simulator With Xcode

The fastest path is the Xcode build-and-run flow. It compiles the app, boots the chosen Simulator, installs the build, and launches it in one action.

  • Open your .xcodeproj or .xcworkspace in Xcode.
  • In the toolbar, click the run-destination menu (next to the scheme) and choose a Simulator device such as iPhone 16 Pro.
  • Press Cmd+R, or choose Product > Run, or click the triangular Run button.
  • Xcode builds the target, boots the Simulator window, installs the app, and launches it automatically.
  • Interact with the running app in the Simulator window using your trackpad and keyboard exactly as a user would tap and type.

If you only want to bring up a Simulator without building a project, you can boot one from the terminal and open the Simulator app window:

# List the available simulators and their UDIDs
xcrun simctl list devices

# Boot a simulator by name (or UDID)
xcrun simctl boot "iPhone 16 Pro"

# Open the Simulator app so you can see the booted device
open -a Simulator

Install and Launch a .app From the Command Line

When you already have a built .app bundle (from CI, a colleague, or a prior build), you can install and launch it on a booted Simulator without opening Xcode. The booted keyword targets whichever simulator is currently running.

# Install a built app bundle onto the booted simulator
xcrun simctl install booted /path/to/MyApp.app

# Launch it by its bundle identifier
xcrun simctl launch booted com.example.MyApp

# Stop the app when you are done
xcrun simctl terminate booted com.example.MyApp

This command-line workflow is what most CI pipelines and automation frameworks use under the hood to put a build on a simulator before running tests against it.

Debug Your App in Xcode

Debugging on the Simulator uses the same tools you would use on a real device, because Xcode attaches the LLDB debugger to the process either way. The main facilities are:

  • Breakpoints: click the gutter to the left of a line to pause execution there. Right-click a breakpoint to add a condition, an ignore count, a log message, or to make it continue automatically after running an action.
  • LLDB console: when paused, type commands in the console at the bottom of the Debug area. Use po to print an object, p for a value, bt for a backtrace, and frame variable to dump locals.
  • Debug area and variables view: step over (F6), step into (F7), and step out (F8), and watch local variables update in the variables pane as you move through the code.
  • Debug navigator: open it from the left sidebar to watch live CPU, memory, energy, disk, and network gauges so you can spot leaks or runaway usage while the app runs.
  • View Debugger: choose Debug > View Debugging > Capture View Hierarchy to explode the UI into a 3D, layer-by-layer view that is ideal for tracking down constraint and layout problems.
  • Console logs: output from print and os_log appears in the Debug area console, so you can trace flow without stopping at breakpoints.

When you want to drive the debugger directly, the most common LLDB commands during a paused session look like this:

(lldb) breakpoint set --name viewDidLoad   # break on a method by name
(lldb) run                                 # start or resume the app
(lldb) po self.someProperty                # print an object's description
(lldb) p count                             # evaluate a value expression
(lldb) bt                                  # show the current backtrace
(lldb) frame variable                      # list local variables in this frame

Stream Simulator Logs From the Terminal

Outside Xcode, you can tail the booted simulator's unified log with simctl spawn. Filtering with a predicate keeps the output limited to your app instead of the entire system.

# Stream all debug-level logs from the booted simulator
xcrun simctl spawn booted log stream --level=debug

# Limit the stream to your app's process
xcrun simctl spawn booted log stream \
  --predicate 'processImagePath endswith "MyApp"'

Simulate Location, Deep Links, and Network Conditions

The Simulator can reproduce many runtime conditions so you can debug code paths that are hard to trigger by hand. A few of the most useful:

  • Open deep links: push a URL into the booted app to test universal links and custom URL schemes without typing them in.
  • Simulate a GPS location: set a fixed coordinate from the command line, or use Features > Location in the Simulator app for a static point or a moving route.
  • Capture media: grab a screenshot or record a video of the session straight from the terminal for bug reports.
  • Throttle the network: install the Network Link Conditioner (from Apple's Additional Tools for Xcode) to emulate slow, lossy, or high-latency connections while the app runs.
# Open a deep link in the booted app
xcrun simctl openurl booted "https://example.com/promo"

# Set a static GPS location (latitude,longitude)
xcrun simctl location booted set 37.3349,-122.0090

# Capture a screenshot and record a video
xcrun simctl io booted screenshot shot.png
xcrun simctl io booted recordVideo demo.mp4

Reset or Erase the Simulator

A clean simulator is often the quickest fix for stale caches, leftover login state, or odd install behaviour. Note that you cannot erase a simulator while it is booted, so shut it down first.

# Shut the device down before erasing it
xcrun simctl shutdown "iPhone 16 Pro"

# Erase content and settings back to a clean state
xcrun simctl erase "iPhone 16 Pro"

# Or wipe every simulator at once
xcrun simctl erase all

In the Simulator app itself, the equivalent action is Device > Erase All Content and Settings. If a simulator refuses to boot or repeatedly crashes rather than just holding stale data, see How to Troubleshoot Simulator Errors?, and for sluggish behaviour, How to Handle Performance Issues with the Simulator?.

iOS Simulator vs a Real iPhone

The Simulator runs your app compiled for your Mac's architecture, which makes it fast to iterate on but means it is not a perfect stand-in for a physical device. Keep these gaps in mind when you decide what a passing run on the Simulator actually proves.

CapabilityiOS SimulatorReal iPhone
CameraNo hardware camera; APIs return mocked or empty dataReal front and rear cameras
Push notificationsNo real APNs; can simulate a payload via xcrun simctl push (Xcode 11.4+)True APNs delivery
GPS and motion sensorsSimulated location only; no accelerometer, gyroscope, or barometerReal GPS and motion hardware
BiometricsFace ID and Touch ID are simulated via the Features menuReal Face ID and Touch ID hardware
Performance and thermalsUses Mac CPU and GPU; not representative of device speed or batteryAccurate on-device performance, thermals, and battery

This is the same trade-off you weigh on Android with an emulator. The Android equivalent of this workflow is covered in Run and Debug Apps on the Emulator.

Run and Debug on Real iOS Devices in the Cloud

The Simulator is excellent for the fast inner loop of writing code and stepping through it, but before release you still want to validate camera flows, push notifications, biometrics, and real performance on actual hardware. Maintaining a shelf of physical iPhones and iPads for every iOS version is expensive, which is where a real device cloud helps. With TestMu AI's Real Device Cloud you can install your build on a remote, physical iPhone or iPad, interact with it live in your browser, capture logs and video, and reproduce the device-only bugs the Simulator simply cannot surface, without managing any local hardware.

Frequently Asked Questions

How do I run an app on the iOS Simulator?

Open your project in Xcode, choose a Simulator device from the run-destination menu in the toolbar, and press Cmd+R (or Product > Run). Xcode builds the app, boots the Simulator, installs the build, and launches it. From the terminal you can boot a simulator with xcrun simctl boot and start an installed app with xcrun simctl launch booted <bundle id>.

How do I debug an app running on the Simulator?

Set breakpoints by clicking the gutter next to a line, then run with Cmd+R. When execution hits a breakpoint, the Debug area opens with the LLDB console and variables view. Use console commands such as po, p, bt, and frame variable to inspect state, step through code with F6/F7/F8, and watch the Debug navigator gauges for CPU and memory.

How do I install a .app on the Simulator from the command line?

Boot a simulator, then run xcrun simctl install booted /path/to/MyApp.app to install the build and xcrun simctl launch booted com.example.MyApp to start it by bundle identifier. The booted keyword targets the currently running simulator, which is what CI pipelines rely on.

How do I reset or erase the iOS Simulator?

Shut the device down first with xcrun simctl shutdown <device>, then run xcrun simctl erase <device> to wipe its content and settings. You cannot erase a booted simulator. In the Simulator app you can also choose Device > Erase All Content and Settings.

Can the Simulator use the camera or receive push notifications?

The Simulator has no physical camera, GPS, or motion sensors, so those APIs return mocked or empty data, and push notifications are not delivered through real APNs. Xcode 11.4 and later let you simulate a remote push by dragging an .apns payload onto the Simulator or using xcrun simctl push. For genuine camera, sensor, and push behaviour you need a real iPhone or a real device cloud.

How do I view my app's logs from the Simulator?

Print statements and os_log output appear in the Xcode Debug area console as the app runs. From the terminal you can stream the booted simulator's unified log with xcrun simctl spawn booted log stream, optionally filtered with a predicate so you only see your app's messages.

Related Questions

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests