1.1 KiB
1.1 KiB
Debugging Strategies
Comprehensive debugging techniques for iOS and macOS development.
Xcode Build Issues
- Clean Build Folder: Product → Clean Build Folder (Cmd+Shift+K)
- Delete Derived Data:
rm -rf ~/Library/Developer/Xcode/DerivedData - Check Build Settings: Verify code signing, Swift version, deployment target
- Read Error Carefully: Xcode errors often include fix-its
- Check Dependencies: Swift Package Manager, CocoaPods, or Carthage issues
Runtime Issues
- Breakpoints: Set symbolic breakpoints for exceptions
- LLDB Commands:
po,expr,frame variablefor inspection - View Debugging: Use Xcode's visual debugger (Debug → View Debugging)
- Memory Graph: Detect retain cycles with Debug → Memory Graph
- Instruments: Profile with Time Profiler, Allocations, Leaks
SwiftUI Debugging
- Preview Crashes: Check
PreviewProviderinitialization - State Updates: Verify state changes on main thread
- View Redrawing: Use
Self._printChanges()to debug updates - Modifiers Order: Order matters (frame before padding vs. padding before frame)