Failed to initialize logging system in Xcode
Problem
When building and running Swift applications in Xcode, developers may encounter the following error:
Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables.
Along with this warning, affected projects experience significantly slowed app launch times—the application may build successfully but take an unusually long time to load. This problem typically occurs across Xcode versions 15.3+ and seems inconsistent across machines, where some team members may experience the issue while others do not with identical SwiftUI projects.
Solutions
Set IDEPreferLogStreaming Environment Variable (Recommended Solution)
- Open your project in Xcode
- Go to Product → Scheme → Edit Scheme...
- Select Run in the left sidebar
- Navigate to the Arguments tab
- In the "Environment Variables" section, click +
- Set these values:
- Name:
IDEPreferLogStreamING
- Value:
YES
- Name:
IDEPreferLogStreaming=YES
- Click Close to save changes
- Clean your build folder (Product → Clean Build Folder)
- Run your project again
Why this works
This addresses Xcode's logging pipeline issues by preferring direct log streaming instead of buffered logging. It resolves both the warning message and associated performance degradation in most cases.
Alternative Environment Variables
For persistent cases, add these supplementary environment variables using the same scheme editor location:
- Name:
IDELogRedirectionPolicy
Value:oslogToStdio
- Name:
OS_ACTIVITY_MODE
Value:disable
IDELogRedirectionPolicy=oslogToStdio
OS_ACTIVITY_MODE=disable
Note
OS_ACTIVITY_MODE=disable
suppresses important console logs from Apple's systems. Use only as temporary workaround.
Clean Test Target Build Phases
For issues persisting after Xcode updates:
- Select your project in Project Navigator
- Choose affected test targets in the left panel (Unit/UI Tests)
- Go to Build Phases → Compile Sources
- Remove all source files not explicitly part of test cases:
- Keep only
*Tests.swift
and*UITests.swift
files
- Keep only
- In Copy Bundle Resources, remove non-essential resources
- Clean and rebuild project
Verifying the Fix
After applying solutions:
- The "Logging Error" warning should disappear
- App launch times should return to normal
- Console logs should appear consistently during debugging
For team projects:
- Share scheme changes through version control by committing
.xcodeproj/xcshareddata/xcschemes/*.xcscheme
files - For environment variable differences, compare schemes using Xcode's Source Control diff tools
Prevention
To avoid recurrence:
- Maintain lean test targets
- Regularly clean build folders after Xcode updates (
⌘⇧K
) - Migrate to Xcode Cloud/Bots for consistent build environments
Conclusion
The "Failed to initialize logging system" error stems from Xcode's internal log handling conflicts. The primary solution—setting IDEPreferLogStreaming=YES
—resolves most occurrences by changing logging mechanisms. For persistent cases, combine environment tweaks with test target cleanup. These solutions avoid drastic measures like OS/Xcode reinstallation while restoring normal development workflow performance.