Skip to content

Ios Nslog Not Showing

DodaTech 2 min read

In this tutorial, you'll learn about How to Fix iOS NSLog Not Showing in Console. We cover key concepts, practical examples, and best practices.

The Problem

Your NSLog messages are not appearing in the Xcode console:

NSLog(@"Button tapped");

Nothing shows up in the debug console or device logs.

Quick Fix

Step 1: Check the debugger is attached

Console output only appears when the debugger is attached. Run the app with:

Product > Run (Cmd+R) — not Product > Archive

Step 2: Use os_log instead of NSLog

WRONG — NSLog may be suppressed:

NSLog(@"User logged in");

RIGHT — use unified logging:

@import os.log;

os_log(OS_LOG_DEFAULT, "User logged in");
os_log(OS_LOG_DEFAULT, "Login failed: %@", error.localizedDescription);

Step 3: Filter the console correctly

Xcode > Debug Area > Show Debug Area (or Shift+Cmd+Y)

In the console:

Console > Search box > enter your log text

Step 4: Check OS_LOG settings

For device logs, console app shows only os_log messages, not NSLog:

os_log_t customLog = os_log_create("com.example.myapp", "network");
os_log(customLog, "Network request started");

Step 5: View device logs

Window > Devices and Simulators > Select device > Open Console

Or use the macOS Console app when the device is connected.

Step 6: Print to stderr directly

import Darwin
fputs("Debug message\n", stderr)

Prevention

  • Use os_log for production logging (structured, privacy-aware).
  • Use print() in Swift as a lightweight debug alternative.
  • Check that the Xcode scheme is set to "Debug" not "Release".

Common Mistakes with nslog not showing

  1. Forgetting deriving (Show, Eq) on custom data types needed for debugging
  2. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  3. Using head and tail instead of pattern matching, causing runtime errors on empty lists

These mistakes appear frequently in real-world IOS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between NSLog and os_log?

NSLog writes to stderr and system log. os_log uses the unified logging system with categories, levels, and privacy controls.

Why does NSLog not show on devices?

On iOS 10+, NSLog messages are not captured by the device console. Use os_log or view logs through Xcode's debugger.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro