Catching Application & System Logs

5.1. How to Catch Application Logs, System Logs, and Stack Traces

The Darwin Build Environment includes a Remote Debug Console for comprehensive logging.

  1. Open Remote Debug Console:

    • Click the link in the builder window (if available after a build).

    • Or, access it from your Windows Start Menu: All Programs > Darwin Build Environment > Remote debug console.

    [Image Placeholder: Screenshot of the Remote Debug Console window interface.]
    Caption: The Remote Debug Console.

Features of the Remote Debug Console:

  • Application Logs (stdout, stderr):

    • Captures everything your iOS or macOS app writes to standard output (stdout) and standard error (stderr).

    • This includes output from NSLog() macros, printf(), fprintf(stderr, ...), cout << ..., and cerr << ....

    • Crucially, it can capture stack dumps if your application crashes.

    • Logs are sent over the network to display on your PC in real-time, even for release builds.

  • System Logs (Syslogs):

    • If your device is connected to your computer via USB and you have iTunes installed, you can capture system logs in ANSI colors.

    • This is invaluable for diagnosing launch issues (e.g., due to invalid entitlements).

    • To enable, tick the "System logs" checkbox in the debug console's bottom status bar.

    • Warning: iOS is a very verbose system, so expect a lot of data.

  • Data Filtering:

    • If the console is flooded with data, you can use filters to:

      • Exclude: Hide messages containing a specific string.

      • Allow: Only show messages containing a specific string.

      • Highlight: Emphasize messages containing a specific string.

  • Stop and Resume Logging:

    • Click the "Stop / Record" button (top right of the console window) to pause or resume log collection.

Enabling Remote Debugging in Your Project:

  1. Set REMOTELOG_IP in make.cmd:

    • Ensure the REMOTELOG_IP variable in your project's make.cmd file is defined.

    • This variable can be:

      • A dotted IP address of your computer (e.g., 192.168.1.10).

      • The string "myself" (the builder will substitute your PC's IP address).

    • Unity Users: Simply tick the "Enable remote debug console" checkbox in the Project Builder for Unity window and specify your PC's IP address there.

  2. Firewall Configuration:

    • The app sends data over TCP ports 5001 and 5002.

    • Ensure the remote debug console window is open on your PC.

    • Make sure no firewall or "Internet Security" software is blocking these ports or the console application.

NOTE on Rebuilding:

  • Each time you toggle the remote debug console feature (e.g., by changing REMOTELOG_IP or the Unity checkbox), your project must be rebuilt from source. This embeds or disembeds additional logging code.

  • If you encounter linker errors like duplicate symbol _main or ld: entry point (_main) undefined, it means you toggled the remote debug console on/off without a full rebuild. To fix this, enable the "Rebuild all files (once)" checkbox in the builder or perform a clean build.

Last updated