How do you optimize iOS app performance?

Answer

iOS performance optimization covers multiple dimensions: 1. Main thread hygiene: all UI on main thread, all heavy work on background. Never block main with network/disk I/O. Profile with Time Profiler in Instruments to find main thread stalls. 2. Image optimization: resize images to display size before setting them (don't display a 4K image in a 44pt thumbnail); use UIGraphicsImageRenderer for resizing; decode images in background before display (decode on main thread causes lag); use ImageIO framework for efficient image loading; AsyncImage (SwiftUI) and SDWebImage/Kingfisher handle this automatically. 3. Table/Collection View: cell reuse (dequeue); lightweight cellForRowAt — do heavy work elsewhere; prefetch with prefetchDataSource; estimate cell heights with estimatedRowHeight; avoid transparent backgrounds. 4. Memory: use weak/unowned to break retain cycles; profile with Memory Graph Debugger and Instruments Allocations; avoid large objects in memory; use lazy loading for expensive properties. 5. Efficient data structures: Dictionary over Array for lookups; Set over Array for membership tests; lazy sequences for large data. 6. Rendering: opaque layers (opaque: true) vs transparent; avoid off-screen rendering (cornerRadius + masksToBounds, shadows); rasterize static complex views (shouldRasterize = true). 7. Launch time: defer non-critical work from applicationDidFinishLaunching; avoid expensive work in +initialize/+load; use dynamic framework loading. 8. Network: cache responses; use background URLSession for large transfers; compression; pagination. 9. Instruments: Time Profiler (CPU), Allocations (memory), Leaks, Core Animation (rendering), Energy (battery).