Core OS and Core Services
When TrailLog saves a hike, many things happen that you never write: a file is created on flash storage, it is encrypted, a GPS chip reports your position, a network socket uploads a backup. iOS organises all of that into layers, and knowing them tells you where to look for any capability.
The rule
Four layers, top to bottom: Cocoa Touch, Media, Core Services, Core OS.
Each layer builds on the ones beneath it. Your app mostly talks to the top, and the lower layers do the heavy lifting underneath.
| Layer | What lives there | Examples |
|---|---|---|
| Cocoa Touch | Screens, touches, app lifecycle | UIKit, SwiftUI, notifications |
| Media | Drawing, animation, images, sound, video | Core Graphics, Core Animation, AVFoundation, Metal |
| Core Services | Data, networking, location, system services | Foundation, Core Data, Core Location, CloudKit |
| Core OS | Kernel, hardware access, security | Darwin kernel, file system, drivers, keychain services |
This lesson covers the two bottom layers.
Core OS is the foundation shared with macOS: the Darwin kernel, memory and process management, the file system, low-level networking, drivers for hardware, and the security machinery (sandboxing, encryption, the Keychain). Apps rarely call it directly; it is what every higher framework ultimately stands on.
Core Services gives you the everyday building blocks that are not about the screen:
- Foundation — strings, dates, numbers, collections,
URLSessionfor networking,FileManager,JSONEncoder. - Core Data and SwiftData — storing object graphs on the device.
- Core Location — the user's position.
- CloudKit — syncing data through iCloud.
import Foundation
import CoreLocation
let saved = Date() // Foundation
let manager = CLLocationManager() // Core LocationThe shortcut
To find the right framework, describe the job without mentioning the screen, then pick the highest layer that does it. Going lower than needed means more code and more ways to get it wrong.
Record the route
"Know where the phone is." Not a screen job; a system service. Core Services → Core Location.
The trap is thinking lower is faster or better. A raw socket is more work than URLSession and loses features like caching and background transfers.
Drills
Answer fast — trust the rule.
Which is the correct order of the iOS layers, top to bottom?
TrailLog needs the user's current position. Which framework?
Which layer contains the kernel, drivers and file system?
Why use URLSession rather than raw sockets to download trail data?
Remember
- Four layers, top to bottom: Cocoa Touch, Media, Core Services, Core OS.
- Shortcut: describe the job, then use the highest layer that does it.
- Core Services is data, networking and location; Core OS is kernel, hardware and security.
