Skip to content

XCode Tips

General Tab:

  • Navigation: Use “Open in Place” for better file management
  • Double-click navigation: Set to “Uses Separate Tab”
  • Theme: Enable “Dark Mode” for reduced eye strain

Text Editing:

- Enable "Line numbers"
- Enable "Code folding ribbon"
- Enable "Page guide" at 120 characters
- Enable "Show invisible characters" when needed
- Set indentation to 4 spaces for Swift, 2 for others

Key Bindings:

  • Customize frequently used commands
  • Export your key bindings for backup
// Recommended project structure:
MyApp/
├── Sources/
├── Models/
├── Views/
├── ViewModels/
├── Services/
└── Utilities/
├── Resources/
├── Tests/
└── Products/

Navigation:

  • ⌘ + 0 - Show/Hide Navigator
  • ⌘ + 1 - Project Navigator
  • ⌘ + 2 - Source Control Navigator
  • ⌘ + 5 - Debug Navigator
  • ⌘ + 6 - Breakpoint Navigator
  • ⌘ + 7 - Test Navigator
  • ⌘ + ⇧ + O - Open Quickly (Game Changer!)
  • ⌘ + J - Jump to filter bar

Editor Management:

  • ⌘ + ⇧ + T - Show/Hide Assistant Editor
  • ⌘ + ⇧ + Y - Show/Hide Debug Area
  • ⌘ + Enter - Standard Editor
  • ⌘ + ⌥ + Enter - Assistant Editor
  • ⌘ + ⇧ + Enter - Show Related Files

Multiple Windows:

  • Use ⌘ + ⇧ + T to create new tabs
  • Drag tabs to create separate windows
  • Use Window > Merge All Windows to consolidate

Area Focus:

  • Triple-click any panel header to maximize
  • Use ⌘ + . to focus on editor
  • Customize toolbar for frequently used actions

Text Manipulation:

  • ⌘ + / - Comment/Uncomment selection
  • ⌃ + I - Re-indent selection
  • ⌘ + ] / ⌘ + [ - Indent left/right
  • ⌃ + ⌘ + E - Edit all in scope
  • ⌃ + 6 - Show document items

Selection & Movement:

  • ⌥ + ↑/↓ - Select scope
  • ⌥ + ←/→ - Move by words
  • ⌥ + Delete - Delete previous word
  • ⌃ + T - Transpose characters
  • ⌘ + D - Duplicate line

SwiftUI Live Previews:

// Use #Preview macro for instant feedback
#Preview {
ContentView()
.previewDisplayName("Light Mode")
}
#Preview("Dark Mode") {
ContentView()
.preferredColorScheme(.dark)
}

Refactoring Shortcuts:

  • ⌃ + ⌘ + E - Extract to method
  • ⌃ + ⌘ + V - Extract variable
  • Right-click → Refactor for menu options
  • Use “Create missing cases” for enums

Create Custom Snippets:

  1. Select code you want to save
  2. Drag to snippets library (bottom-right)
  3. Set completion shortcut and platform
  4. Use placeholders: <#placeholder#>

Essential Snippets:

  • SwiftUI View template
  • Network request template
  • Core Data fetch request
  • Unit test template

Conditional Breakpoints:

// Right-click breakpoint → Edit Breakpoint
// Condition: index == 5
// Action: Log Message "Reached index 5"
// Options: Automatically continue after evaluating

Symbolic Breakpoints:

  • Add via Breakpoint Navigator (+ button)
  • Useful for:
    • -[UIViewController viewDidLoad]
    • -[NSException raise]
    • Custom methods

Exception Breakpoints:

  • Always enable “All Objective-C exceptions”
  • Enable “Swift Error Breakpoints” for Swift errors

Essential LLDB Commands:

po variableName // Print object description
p variableName // Print raw value
expression variableName = newValue // Change value at runtime
bt // Backtrace
frame variable // Show local variables
thread backtrace // Show call stack
// Advanced:
memory read &variable // Read memory
register read // Show CPU registers

Custom LLDB Commands:

// Add to ~/.lldbinit
command alias pvc expression -l objc -O -- [`UIApplication sharedApplication` keyWindow].rootViewController
command alias pviews expression -l objc -O -- [[[UIApplication sharedApplication] keyWindow] recursiveDescription]

3D View Hierarchy:

  • Click “Debug View Hierarchy” during debug
  • Use sliders for layer inspection
  • Check auto layout issues in real-time
  • Export view hierarchy for analysis

Memory Graph Debugger:

  • Click “Debug Memory Graph” button
  • Identify retain cycles visually
  • Check for memory leaks
  • Export memory graphs for documentation

Build Settings Optimization:

- Enable "Parallelize Build"
- Set "Build Active Architecture Only" to Yes for Debug
- Use "New Build System" for better performance
- Enable "Incremental Builds"

Compilation Speed:

  • Use ⌘ + 9 to monitor build times
  • Enable “Whole Module Optimization” for Release
  • Use -Xfrontend -warn-long-expression-type-checking=100
  • Split large files into extensions

Custom Schemes:

  • Create Debug, Release, and Testing schemes
  • Configure different environment variables
  • Set custom launch arguments
  • Pre-actions and post-actions for automation

Environment Variables:

// Add to scheme arguments:
-OS_ACTIVITY_MODE disable
-NSDoubleLocalizedStrings YES

Essential Instruments:

  • Time Profiler - CPU performance
  • Allocations - Memory usage
  • Leaks - Memory leaks detection
  • Network - API calls monitoring
  • SwiftUI - View performance

Quick Profiling:

  • ⌘ + I - Launch Instruments
  • Use “Profile” instead of “Run” for performance testing
  • Save instrument templates for repeated use

Source Control Navigator:

  • ⌘ + 2 - Open Source Control navigator
  • View all branches and remotes
  • Create and manage branches visually
  • Resolve conflicts with built-in tool

Essential Git Operations:

  • ⌃ + ⌘ + C - Commit changes
  • ⌃ + ⌘ + P - Push to remote
  • ⌃ + ⌘ + X - Pull from remote
  • Use “Stash” for temporary changes

Visual Merge Tool:

  • Three-pane view for conflicts
  • Inline resolution options
  • Accept incoming/current or merge manually
  • Use “Compare” before committing

Blame Annotation:

  • Right-click in editor → “Show Blame”
  • See who changed each line
  • Jump to specific commits
  • Integrated with commit messages

Keyboard Shortcuts:

  • ⌘ + = - Size to fit content
  • ⌘ + [ / ] - Send backward/forward
  • ⌥ + Drag - Duplicate elements
  • ⌘ + T - Show fonts panel
  • ⌃ + ⌘ + T - Show colors panel

Auto Layout Mastery:

  • ⌥ + Drag between views for constraints
  • Use “Embed in Stack” for quick layouts
  • “Reset to Suggested Constraints” when stuck
  • Use “Update Frames” after constraint changes

Canvas Power Features:

  • ⌘ + ⌥ + Return - Toggle Canvas
  • ⌃ + ⌘ + Click - Quick actions
  • Drag from Library to code or canvas
  • Use “Pin” to keep previews active

Dynamic Previews:

#Preview("Multiple Devices") {
Group {
ContentView()
.previewDevice("iPhone 15 Pro")
ContentView()
.previewDevice("iPad Pro (12.9-inch)")
}
}

Test Shortcuts:

  • ⌘ + U - Run all tests
  • ⌘ + ⌥ + U - Run current test
  • ⌃ + ⌥ + ⌘ + U - Test current function
  • Click diamond in gutter to run single test

Test Plans:

  • Create multiple test configurations
  • Different environments per test plan
  • Code coverage per test plan
  • Parallel testing across multiple devices

Record & Optimize:

  • Use recording feature to generate base tests
  • Add accessibility identifiers for stability
  • Use waitForExistence(timeout:) for async elements
  • Implement Page Object pattern

Performance Testing:

func testPerformanceExample() {
measure {
// Code to measure
heavyCalculation()
}
measure(metrics: [XCTMemoryMetric()]) {
// Memory measurement
}
}

Custom Behaviors:

  • Xcode → Behaviors → Edit Behaviors
  • Configure actions for:
    • Build starts/completes
    • Testing succeeds/fails
    • Debugging starts/pauses

Example Behavior:

- Build Succeeds: Play sound, show notification
- Build Fails: Show debug area, navigate to issues
- Testing Completes: Show test navigator

Xcode Extensions:

  • Install via Xcode → Settings → Extensions
  • Popular extensions:
    • SwiftLint for code style
    • GitLink for enhanced Git
    • Rainbow for colorful logs

Custom Scripts:

  • Add build phase scripts
  • Use "${SRCROOT}/scripts/my_script.sh"
  • Pre-actions and post-actions in schemes

Automated Signing:

  • Enable “Automatically manage signing”
  • Use development teams for automatic provisioning
  • Manual signing for complex configurations

Archive & Export:

  • ⌘ + ⇧ + B - Analyze archive
  • ⌘ + B - Build for archive
  • Use “Distribute App” for all distribution methods
  • Save export options for repeated use

Quick Help:

  • ⌥ + Click on symbol for quick documentation
  • ⌥ + ⌘ + / - Add documentation template
  • ⌃ + ⌘ + ? - Show quick help inspector

Documentation Browser:

  • ⌘ + ⇧ + 0 - Open Developer Documentation
  • Download docs for offline access
  • Use search filters for precise results

Destination Management:

  • Use destination selector in toolbar
  • Create custom destinations
  • Simulate different devices and OS versions
  • Use “Window → Devices and Simulators” for management

Universal App Development:

  • Use #if os(iOS) for platform-specific code
  • Share SwiftUI views across platforms
  • Test on multiple destinations simultaneously

  1. Master ⌘ + ⇧ + O - Open any file instantly
  2. Use Multiple Cursors - ⌃ + ⇧ + Click
  3. Live Previews - SwiftUI canvas for instant feedback
  4. Custom Snippets - Save and reuse code patterns
  5. Advanced Breakpoints - Debug smarter, not harder
  • Enable parallel builds
  • Use new build system
  • Monitor build times regularly
  • Optimize asset catalogs
  • Use proper dependency management
Navigation:
⌘ + ⇧ + O - Open Quickly
⌘ + 1-8 - Navigate between panels
⌘ + J - Filter current panel
Editing:
⌘ + / - Toggle comments
⌃ + I - Re-indent
⌥ + ⌘ + [ - Move line up
Debugging:
⌘ + \ - Toggle breakpoint
⌘ + Y - Activate/deactivate breakpoints
⌃ + ⌘ + Y - Continue execution