Program
Essence
A program = data + algorithms packaged into an executable: it takes input (touches, network, files), transforms it and produces output (the screen, a write to disk, a request). The CPU understands only machine instructions and bytes, so everything else — numbers, strings, objects — is an abstraction that the compiler and runtime map onto memory.
What a program is on iOS
- The
.appbundle: a Mach-O binary,Info.plist, resources (assets, storyboards, localisations), frameworks. Signed with a certificate — otherwise the system will not launch it. - The entry point:
@mainon anApptype (SwiftUI) or aUIApplicationDelegate; the compiler generates amainfunction that callsUIApplicationMain. - The process: at launch
dyldloads the binary and dynamic libraries, the main thread is created with a run loop that waits for events (touches, timers, network) and hands them to your code. The app is one process; extensions (widgets, share extension) are separate ones. - The lifecycle: not running → inactive → active → background → suspended. In the background the app gets a few seconds, then the system freezes it and may evict it under memory pressure.
import SwiftUI
@main
struct DevPrepApp: App { // entry point: the compiler generates main()
var body: some Scene {
WindowGroup { ContentView() }
}
}
struct ContentView: View {
var body: some View { Text("Hello") }
}
Static and dynamic
- Static — what is in the binary: code, types, resources.
- Dynamic — what exists only while running: heap objects, the call stack, open connections, UI state. That is what is lost when the system kills the process, so state is persisted to disk (UserDefaults, SwiftData, files) and restored on the next launch.
What the interviewer looks for
Do you understand that your code does not "spin" on its own: the main thread's run loop calls it in response to events, and anything heavy on that thread blocks the UI. This is the bridge to concurrency and the app lifecycle.