How can I get the console logs from the iOS Simulator?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
The fastest way to get console logs from the iOS Simulator is through Xcode's debug console, which appears automatically when you run your app with Cmd + R. For more advanced filtering, use the xcrun simctl spawn command in Terminal or open the macOS Console app. Each method serves a different debugging workflow, from quick print() checks to structured log analysis.
Method 1: Xcode Debug Console
This is the default approach and covers most debugging scenarios.
Setup
- Open your project in Xcode and select an iOS Simulator as the run destination.
- Run the app with
Cmd + R. - Open the debug console with
Cmd + Shift + Cor navigate toView > Debug Area > Activate Console.
The console appears at the bottom of the Xcode window and shows output in real time.
What Appears in the Console
The Xcode console captures output from:
The key difference between print() and NSLog() is that NSLog() writes to the system log with a timestamp and process identifier, while print() writes only to stdout. Both appear in the Xcode console, but only NSLog() output appears in the macOS Console app.
Filtering Console Output
Xcode's console has a filter bar at the bottom. You can type keywords to narrow the output, or use the toggle buttons to show only your app's output versus all process output.
For structured filtering, use the os logging framework instead of print():
This produces log entries with severity levels that Xcode can filter by category and type.
Method 2: Terminal With xcrun simctl
The simctl tool gives you direct access to simulator log streams from the command line. This is useful when you want to capture logs without Xcode or apply complex filtering.
List Available Simulators
This shows only currently running simulators with their UDIDs.
Stream Logs in Real Time
This streams all log output from the booted simulator. The output is verbose, so filtering is essential.
Filter by Process Name
Filter by Subsystem and Category
If your app uses the os logging framework:
Filter by Message Content
Output Styles
Method 3: macOS Console App
The Console app (Applications > Utilities > Console) provides a graphical interface for browsing logs from all processes, including simulators.
Steps
- Open Console.app.
- In the left sidebar, find the simulator device under the devices list. Booted simulators appear by name.
- Click the simulator device to view its log stream.
- Use the search bar to filter by your app's bundle identifier or specific keywords.
The Console app is particularly useful when you need to see logs from system frameworks that interact with your app, such as networking, push notifications, or background task scheduling. These logs are not visible in the Xcode console.
Method 4: Reading Log Archives
For debugging crashes or issues that already happened, you can read historical logs:
Collecting a Log Archive
To share logs with a colleague or attach them to a bug report:
Open the .logarchive file with Console.app for a full browsable view.
Comparison of Methods
| Method | Real-time | Historical | Filtering | Best for |
| Xcode Console | Yes | No | Basic text filter | Day-to-day development |
xcrun simctl log stream | Yes | No | Predicate-based (powerful) | Advanced filtering, headless CI |
xcrun simctl log show | No | Yes | Predicate-based (powerful) | Post-crash analysis |
| macOS Console.app | Yes | Yes | GUI search bar | System-level log inspection |
Logging Best Practices for Simulator Debugging
Use os.Logger Instead of print()
The os logging framework provides structured output with severity levels, subsystem grouping, and automatic redaction of sensitive data in release builds:
The privacy: .private modifier redacts the value in non-debug builds, preventing sensitive data from leaking into production logs.
Add Signpost Intervals for Performance
Signpost intervals appear in Instruments and help you correlate log output with performance traces.
Common Pitfalls
Relying exclusively on print() means your log output disappears the moment the Xcode session ends. print() does not write to the system log, so the Console app and log show commands cannot retrieve it. Use os.Logger or NSLog() for anything you might need to review after the fact.
Forgetting to filter by process name when using simctl log stream produces an overwhelming volume of system log output. Always add a --predicate filter to focus on your app's process.
Assuming the Xcode console shows all system logs is incorrect. Xcode only shows stdout/stderr from your process and os log output at the default level or above. System framework logs, kernel messages, and other process output require the Console app or simctl.
Not checking that the simulator is actually booted before running simctl spawn booted causes a "No devices are booted" error. Run xcrun simctl list devices booted first to verify.
Using NSLog() heavily in production code introduces performance overhead because it performs synchronous I/O. Reserve it for debug builds or migrate to os.Logger, which is designed for high-performance logging.
Summary
- Use the Xcode debug console (
Cmd + Shift + C) for standard development logging. - Use
xcrun simctl spawn booted log streamwith--predicatefilters for advanced terminal-based log analysis. - Use
xcrun simctl spawn booted log showto read historical logs after a crash or issue. - Use the macOS Console app to inspect system-level logs that do not appear in Xcode.
- Prefer
os.Loggeroverprint()for structured, filterable, production-safe logging. - Always filter by process name or subsystem to avoid drowning in system log noise.
Related reading
- How can I get the current screen orientation?
- How can I get the font size and font name of a UILabel?
- How can I get the height and width of an uiimage?
- How can I get the iOS 7 default blue color programmatically?
- How can I get the current stack trace in Java?
- How can I gracefully handle a Kafka outage?
- How can I import Swift code to Objective-C?
- How can I increase the Tap Area for UIButton?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.