Keywords: Xcode | iOS Development | Log Configuration
Abstract: This article provides a comprehensive guide on configuring Xcode 8 and later versions to hide various system logs generated during iOS application runtime. These logs originate from subsystems like UIKit, BaseBoard, and FrontBoard, and while useful for system debugging, they often interfere with developers' ability to view their own log outputs during daily development. The article presents two solutions: one that simply disables all activity logs, and another more refined approach that only disables logs in the simulator while preserving them on physical devices. Through step-by-step instructions and code examples, developers can quickly resolve log interference issues and improve development efficiency.
Problem Background
When creating new blank projects in Xcode 8 and later versions, running the application generates numerous system logs in the console. These logs originate from various iOS subsystems, such as:
2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, enable_level: 0, persist_level: 0, propagate_with_activity: 0
2016-06-13 16:33:34.406323 TestiOS10[8209:100607] Created DB, header sequence number = 248
2016-06-13 16:33:34.409564 TestiOS10[8209:100611] subsystem: com.apple.UIKit, category: HIDEvents, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0While these logs are valuable for system debugging, they significantly interfere with developers' ability to view their own NSLog or print outputs during daily development work.
Solution 1: Complete Activity Log Disable
The simplest solution involves setting an environment variable to disable these system logs:
- From the Xcode menu, open:
Product>Scheme>Edit Scheme - In Environment Variables, set
OS_ACTIVITY_MODE=disable
This configuration completely disables system activity log output, allowing the console to display only the developer's own log information.
Solution 2: Simulator-Specific Configuration
For more granular control, you can configure the system to disable logs only in the simulator while preserving them on physical devices:
- In
Product > Scheme > Edit Scheme... > Run (Debug), set theOS_ACTIVITY_MODEenvironment variable to${DEBUG_ACTIVITY_MODE} - Navigate to project build settings and add a user-defined setting named
DEBUG_ACTIVITY_MODE - Expand this setting and click
+next toDebugto add a platform-specific value - Select the dropdown and change it to "Any iOS Simulator", then set its value to "disable"
With this configuration, system logs won't appear when running in the simulator, while full log information remains available during device execution.
Technical Principle Analysis
These system logs originate from iOS's Unified Logging System, which provides structured logging capabilities. The OS_ACTIVITY_MODE environment variable controls the behavior of this logging system:
- When set to
disable, the system suppresses most debugging and diagnostic log outputs - By default, the system outputs log information at all levels
- This configuration only affects system logs and doesn't impact developers' own
NSLogorprintstatements
Best Practice Recommendations
In practical development, we recommend:
- Use Solution 2 during development phases to maintain clean output in the simulator
- Preserve complete system logs during physical device debugging for problem diagnosis
- No configuration is needed for production versions, as system logs are optimized by default in release builds