Post

iOS System Architecture Cheatsheet

Quick reference for the four layers of iOS system architecture and their key frameworks.

iOS System Architecture Cheatsheet

Concept Summary

• iOS uses a four-layer architecture: Core OS, Core Services, Media, and Cocoa Touch • Each layer builds on the one below — higher layers provide more abstraction • The XNU kernel (Mach + BSD) sits at the bottom, managing hardware and security • Apps should always prefer the highest-level API available • Apps never communicate with hardware directly — all access goes through the layers

Diagram

flowchart TD
    A["Cocoa Touch<br>UIKit · SwiftUI · MapKit"] --> B["Media<br>AVFoundation · Metal · Core Animation"]
    B --> C["Core Services<br>Foundation · Core Data · URLSession"]
    C --> D["Core OS<br>XNU Kernel · Security · Accelerate"]
    D --> E["Hardware"]

Key APIs

LayerKey FrameworksPurpose
Cocoa TouchUIKit, SwiftUI, WidgetKitUI, gestures, app lifecycle
MediaAVFoundation, Metal, Core GraphicsAudio, video, GPU, drawing
Core ServicesFoundation, Core Data, URLSessionData, networking, location
Core OSSecurity, Accelerate, LocalAuthenticationKernel, crypto, biometrics

Common Interview Questions

What are the four layers of iOS architecture and what does each one do?

What kernel does iOS use, and how does it relate to macOS?

Why should developers prefer higher-level frameworks over lower-level APIs?

Common Pitfalls

⚠️ Storing passwords in UserDefaults instead of the Keychain (Core OS Security framework)

⚠️ Doing heavy Core Graphics rendering on the main thread — causes UI jank

⚠️ Using low-level C APIs when a Swift framework already wraps the functionality

Quick Reference Table

ScenarioRecommended FrameworkLayer
Build a screenUIKit / SwiftUICocoa Touch
Make HTTP requestsURLSessionCore Services
Store structured dataCore Data / SwiftDataCore Services
Play audio/videoAVFoundationMedia
Encrypt sensitive dataSecurity / KeychainCore OS
Biometric loginLocalAuthenticationCore OS
Custom 2D drawingCore GraphicsMedia
GPU compute / 3DMetalMedia
This post is licensed under CC BY 4.0 by the author.