Nanfeng

Notes on software development, code, and curious ideas

Useful Xcode Paths and Debugging Tools on macOS

Several useful Xcode and macOS paths are listed below. Inspect each target before deleting anything, close Xcode and Simulator first, and prefer Xcode’s own management UI when available.

Purpose Path
Hosts file /private/etc/hosts
Legacy Xcode plug-ins ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins
Build index and DerivedData ~/Library/Developer/Xcode/DerivedData
Device support symbols ~/Library/Developer/Xcode/iOS DeviceSupport
Simulator devices and their data ~/Library/Developer/CoreSimulator/Devices
Organizer archives ~/Library/Developer/Xcode/Archives
Provisioning profiles ~/Library/MobileDevice/Provisioning Profiles
CocoaPods cache ~/Library/Caches/CocoaPods

DerivedData can be regenerated, although the next build and index may take longer. Simulator devices and archives can contain irreplaceable app data or archived builds, so manage them through Window → Devices and Simulators and Window → Organizer or back them up first.

Find retain cycles and leaks

Run Product → Analyze for static diagnostics. For runtime leaks, choose Xcode → Open Developer Tool → Instruments, then use the Leaks and Allocations templates. Runtime tools can reveal issues that static analysis cannot observe.

Diagnose zombie objects

Enable Zombie Objects under Product → Scheme → Edit Scheme → Diagnostics, or use Instruments’ Zombies template. Zombies intentionally retain metadata about deallocated Objective-C objects and increase memory usage, so use them only in a debug run.

Choose between multiple Xcode installations

Xcode’s Settings → Locations → Command Line Tools selects a toolchain for many command-line operations. The terminal can also inspect and change the active developer directory:

1
2
xcode-select --print-path
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

Confirm the target path before switching, especially on build machines that intentionally use a pinned Xcode version.

+