Courses / Mobile Application Development (CDE-315) – BS CS 5th Semester
Week 4 Theory – iOS – Architecture, Frameworks, App Lifecycle and Development Tools
Week 4 – iOS: Architecture and Framework · 80 min read · 39 MCQs to check yourself
Getting started with SwiftUI in Xcode (2026, beginners)
(Optional, long) freeCodeCamp – SwiftUI course: create an iOS app from scratch
1. iOS – history and ecosystem
iOS (originally iPhone OS) is Apple's mobile operating system for the iPhone. It was introduced with the first iPhone by Steve Jobs in January 2007 (released June 2007).
| Year | Milestone |
|---|---|
| 2007 | iPhone and iPhone OS 1 – multi-touch UI, no third-party apps |
| 2008 | iPhone OS 2 – App Store and the official SDK for developers |
| 2010 | Renamed iOS (iOS 4) – multitasking, FaceTime; iPad launched |
| 2013 | iOS 7 – flat design |
| 2014 | Swift language announced (WWDC) |
| 2019 | SwiftUI introduced; iPad gets its own name iPadOS |
| 2020 | Widgets on the home screen (iOS 14) |
| 2025 | Version numbers jump to the year: iOS 26 with the "Liquid Glass" design |
| 2026 | iOS 27, Xcode 27 and Swift 6.x |
Related Apple OSes share the same core: iPadOS, macOS, watchOS, tvOS, visionOS (Apple Vision Pro).
Characteristics of iOS
- Closed source and vertically integrated – Apple designs the hardware (A-series chips), OS and store, giving smooth performance and strong security.
- Low fragmentation – few device models; most users update quickly to the latest iOS.
- Strict App Review – every app is reviewed against the App Store Review Guidelines.
- Sandboxed apps – each app has its own container; access to photos, location, contacts, camera needs user permission.
- Kernel: XNU (hybrid of the Mach microkernel and BSD Unix), part of Darwin.
2. iOS architecture – four layers
iOS is organised in four abstraction layers. Apps should use the highest layer possible; lower layers give more control but more work.
+--------------------------------------------------+
| Cocoa Touch (UIKit, SwiftUI, MapKit, UserNotif.) | <- highest level, your app talks here
+--------------------------------------------------+
| Media (Core Graphics, Core Animation, Metal, |
| AVFoundation, Core Audio, Core Image) |
+--------------------------------------------------+
| Core Services (Foundation, Core Data, Core |
| Location, CloudKit, Networking, SQLite, Contacts)|
+--------------------------------------------------+
| Core OS (XNU kernel, drivers, security, |
| Bluetooth, file system, power, Accelerate) |
+--------------------------------------------------+
| Hardware (A-series chip) |
2.1 Core OS layer (lowest)
- Built on the Darwin / XNU kernel: memory management, threads, file system (APFS), networking, device drivers, power management.
- Security framework (keychain, encryption, Secure Enclave for Face ID/Touch ID data).
- Core Bluetooth, External Accessory, Accelerate (fast maths/DSP), Local Authentication (Face ID/Touch ID).
2.2 Core Services layer
Fundamental system services used by all apps:
| Framework | Purpose |
|---|---|
| Foundation | Basic types: strings, dates, collections, URL loading, threads |
| Core Data / SwiftData | Object graph and persistence (database) framework |
| Core Location | GPS and location |
| CloudKit / iCloud | Store data in iCloud |
| Network / URLSession | HTTP and networking |
| Contacts, EventKit | Address book, calendar |
| SQLite | Embedded database |
| Core Motion | Accelerometer, gyroscope, pedometer |
| StoreKit | In-app purchases |
| HealthKit | Health and fitness data |
2.3 Media layer
Graphics, audio and video:
| Framework | Purpose |
|---|---|
| Core Graphics (Quartz) | 2-D drawing |
| Core Animation | Smooth animations |
| Metal | Low-level, high-performance 3-D graphics and GPU computing (replaced OpenGL ES) |
| Core Image | Image filters |
| AVFoundation / AVKit | Record and play audio/video |
| Core Audio | Low-level audio |
| PhotoKit | Photo library |
| SpriteKit / SceneKit / RealityKit | 2-D games, 3-D scenes, augmented reality |
2.4 Cocoa Touch layer (highest)
The frameworks for building app interfaces and handling touch events:
| Framework | Purpose |
|---|---|
| UIKit | Classic, imperative UI framework: views, controls, view controllers, touch, gestures, app lifecycle |
| SwiftUI | Modern declarative UI framework (2019) for all Apple platforms |
| MapKit | Embedded maps and annotations |
| UserNotifications | Local and push notifications |
| Push notifications (APNs) | Apple Push Notification service |
| EventKit UI, Contacts UI, MessageUI | Standard calendar, contact and mail/SMS composer screens |
| GameKit | Game Center |
| Auto Layout & Storyboards | Adaptive layouts and visual interface design |
| Multitasking, gesture recognisers | Tap, swipe, pinch, long press |
Cocoa Touch vs Cocoa: Cocoa is the macOS framework set (AppKit); Cocoa Touch is its touch-based counterpart for iOS (UIKit).
Android vs iOS architecture (comparison)
| Android layer | iOS layer (approx.) |
|---|---|
| Linux kernel + HAL | Core OS (XNU/Darwin) |
| Native libraries + ART | Core Services + Media |
| Java/Kotlin API framework | Cocoa Touch (UIKit/SwiftUI) |
| Apps | Apps |
3. iOS frameworks: UIKit and SwiftUI
UIKit (imperative, 2008)
- UI built with UIView subclasses (UILabel, UIButton, UITextField, UIImageView, UITableView, UICollectionView) and UIViewController objects (one per screen).
- Screens designed in Interface Builder using Storyboards/XIB files or in code; Auto Layout constraints adapt to sizes.
- Navigation: UINavigationController (push/pop stack), UITabBarController (tabs).
- Pattern: MVC – Model-View-Controller.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var nameLabel: UILabel! // connected from storyboard
override func viewDidLoad() {
super.viewDidLoad()
nameLabel.text = "Hello iOS"
}
@IBAction func buttonTapped(_ sender: UIButton) { // connected action
nameLabel.text = "Button tapped"
}
}
@IBOutlet– reference from code to a UI element in the storyboard.@IBAction– method called by a UI event (tap).
SwiftUI (declarative, 2019)
- You describe the UI as a function of state; when the state changes, SwiftUI updates the view automatically.
- Live Preview in Xcode; works on iOS, iPadOS, macOS, watchOS, tvOS, visionOS.
- Pattern usually MVVM.
import SwiftUI
struct ContentView: View {
@State private var count = 0
var body: some View {
VStack(spacing: 16) {
Text("Taps: \(count)").font(.title)
Button("Tap me") { count += 1 }
.buttonStyle(.borderedProminent)
}
.padding()
}
}
| UIKit | SwiftUI | |
|---|---|---|
| Style | Imperative (change views step by step) | Declarative (describe UI for a state) |
| Year | 2008 | 2019 |
| Layout | Storyboards + Auto Layout | Stacks (VStack, HStack, ZStack) and modifiers |
| Min iOS | All | iOS 13+ |
| Android equivalent | XML Views | Jetpack Compose |
Swift language highlights
- Created by Apple (2014), open source; safe, fast and modern.
- Optionals (
String?) to handle missing values safely;let(constant) /var(variable); type inference; closures; structs and protocols;async/awaitconcurrency; Swift 6 adds strict data-race safety. - Objective-C – older, C-based language (Smalltalk-style messages,
[obj method]), still in legacy code; interoperable with Swift.
4. iOS app structure and lifecycle
App structure
- App bundle (.app) – executable, resources (images in Assets.xcassets), storyboards and Info.plist.
- Info.plist – app configuration (like Android's manifest): bundle identifier, version, display name, privacy usage descriptions such as
NSCameraUsageDescription,NSLocationWhenInUseUsageDescription(the text shown when asking permission). - Bundle identifier – unique ID like
com.university.campusapp(Android: applicationId). - AppDelegate – handles app-level events (launch, push notification registration).
- SceneDelegate (iOS 13+) – handles each UI window/scene (iPad can have several).
- In SwiftUI apps an
@main struct MyApp: Appreplaces most of this.
App states
| State | Meaning |
|---|---|
| Not running | App not launched or terminated |
| Inactive | In foreground but not receiving events (e.g. incoming call overlay) |
| Active | In foreground and receiving events – normal running |
| Background | Not visible but executing code (limited time or allowed background modes) |
| Suspended | In memory but not executing; may be purged when memory is low |
Key callbacks: application(_:didFinishLaunchingWithOptions:), sceneDidBecomeActive, sceneWillResignActive, sceneDidEnterBackground, sceneWillEnterForeground.
View controller lifecycle (UIKit)
loadView → viewDidLoad (once, set up UI) → viewWillAppear → viewDidAppear → viewWillDisappear → viewDidDisappear (and deinit). Compare with Android's onCreate → onStart → onResume → onPause → onStop → onDestroy.
MVC in iOS
- Model – data and business logic (Student, database).
- View – what the user sees (UILabel, UIButton, storyboard).
- Controller – UIViewController connecting model and view, handling actions. (Large controllers – "Massive View Controller" – led many teams to MVVM.)
5. iOS development tools and distribution
| Tool | Purpose |
|---|---|
| Mac computer | Required – Xcode runs only on macOS (Apple silicon Mac recommended) |
| Xcode | IDE: editor, Interface Builder, SwiftUI previews, compiler (LLVM/Swift), debugger, Instruments (profiling), iOS Simulator |
| Swift Playgrounds | Learn Swift on iPad/Mac; can even build simple apps |
| Apple ID / Developer account | Free account can run apps on your own iPhone for testing; Apple Developer Program (USD 99/year) needed to publish |
| TestFlight | Beta-testing builds with up to 10,000 external testers |
| App Store Connect | Website to manage listings, builds, pricing, reviews |
| CocoaPods / Swift Package Manager | Dependency managers for third-party libraries |
| Certificates & provisioning profiles | Code signing – prove the developer's identity and which devices/app IDs can run the app |
Publishing steps: enrol in the program → create the App ID/bundle ID → archive the app in Xcode (Product → Archive) → upload the IPA build to App Store Connect → fill metadata, screenshots, privacy details ("nutrition labels") → submit for App Review (usually 1–2 days) → release.
For students without a Mac: learn concepts with videos, use cloud Macs, or build iOS apps with Flutter/React Native and compile on a Mac or a cloud build service (e.g. Codemagic, Expo EAS) when needed.
Short and long questions
1. Give four characteristics of iOS.
Model answer
(1) Closed-source, vertically integrated with Apple hardware. (2) Low fragmentation – few models and fast adoption of updates. (3) Strict App Store review and sandboxed apps with permission prompts. (4) Built on the Darwin/XNU kernel and developed with Swift/Objective-C in Xcode.
2. Explain the architecture of iOS with a diagram. Describe each layer and its important frameworks.
Model answer
iOS has four layers above the hardware; apps should use the highest layer that meets their needs (draw: Cocoa Touch / Media / Core Services / Core OS / Hardware).
Core OS – the lowest layer, built on the Darwin XNU kernel (Mach + BSD). It provides memory and process management, threads, the APFS file system, networking, device drivers and power management, plus Security (keychain, encryption, Secure Enclave), Local Authentication (Face ID/Touch ID), Core Bluetooth, External Accessory and Accelerate.
Core Services – fundamental services for all apps: Foundation (strings, collections, dates, URL loading), Core Data / SwiftData (persistence), SQLite, Core Location (GPS), CloudKit/iCloud, Network/URLSession, Contacts, EventKit, Core Motion, StoreKit (in-app purchase) and HealthKit.
Media – graphics, audio and video: Core Graphics/Quartz (2-D drawing), Core Animation, Metal (GPU 3-D graphics), Core Image (filters), AVFoundation/AVKit (record and play media), Core Audio, PhotoKit, SpriteKit/SceneKit/RealityKit.
Cocoa Touch – the top layer for building app interfaces and handling touch: UIKit (views, controls, view controllers, gestures, app lifecycle), SwiftUI (declarative UI), MapKit, UserNotifications and push notifications (APNs), MessageUI, Contacts UI, GameKit, Auto Layout and storyboards.
The layered design hides hardware complexity, provides consistent APIs, and lets Apple optimise lower layers without breaking apps. Compared with Android: Core OS ≈ Linux kernel + HAL, Core Services and Media ≈ native libraries/runtime, Cocoa Touch ≈ the application framework.
3. Compare the architectures of Android and iOS briefly.
Model answer
Both are layered. Android: Linux kernel → HAL → native libraries and ART → Java/Kotlin API framework → apps. iOS: Core OS (XNU kernel) → Core Services → Media → Cocoa Touch → apps. Android is open source and runs on many vendors' hardware; iOS is closed and runs only on Apple devices; Android apps run on ART bytecode while iOS apps are compiled to native ARM code.
4. What is Cocoa Touch?
Model answer
Cocoa Touch is the top layer of iOS consisting of frameworks for building app UIs and handling touch input – mainly UIKit (and SwiftUI), plus MapKit, UserNotifications, GameKit and the standard UI controllers. It is the touch-screen counterpart of Cocoa (AppKit) on macOS.
5. Name the four layers of iOS architecture and give two frameworks in each.
Model answer
Cocoa Touch – UIKit, SwiftUI (also MapKit, UserNotifications); Media – Core Animation, AVFoundation (Metal, Core Graphics); Core Services – Foundation, Core Data (Core Location, CloudKit); Core OS – Security, Core Bluetooth (Accelerate, Local Authentication) on the XNU kernel.
6. Describe the structure and lifecycle of an iOS app. Explain UIKit (MVC) and SwiftUI with small code examples, and compare them with Android's View system and Jetpack Compose.
Model answer
Structure: an iOS app is a bundle containing the compiled executable, assets (Assets.xcassets), storyboards and Info.plist (bundle identifier, version, privacy usage descriptions). The AppDelegate handles app-level events and the SceneDelegate manages windows; SwiftUI apps start from an @main App struct.
Lifecycle states: Not running → Inactive → Active; when the user leaves, Background and then Suspended; the system may terminate suspended apps. View controllers have viewDidLoad, viewWillAppear, viewDidAppear, viewWillDisappear and viewDidDisappear, similar to Android's activity callbacks.
UIKit with MVC: the Model holds data, the View is made of UIView objects designed in storyboards with Auto Layout, and the Controller (UIViewController) connects them through @IBOutlet properties and @IBAction methods, e.g. an action buttonTapped that sets nameLabel.text = "Button tapped". Navigation uses UINavigationController and UITabBarController. UIKit is imperative – the code changes views directly.
SwiftUI: a declarative framework in which a struct conforming to View returns a body built from VStack, HStack, Text, Button etc.; @State var count = 0 with Button("Tap") { count += 1 } automatically refreshes Text("Taps: \(count)"). It offers live previews and runs on all Apple platforms; usually combined with MVVM.
Comparison with Android: UIKit ↔ Android XML View system (both imperative, separate layout files, Activity/ViewController per screen); SwiftUI ↔ Jetpack Compose (both declarative, state-driven, written entirely in the language – Swift or Kotlin). Info.plist ↔ AndroidManifest.xml, viewDidLoad ↔ onCreate, Xcode ↔ Android Studio, IPA ↔ APK/AAB.
7. What are IBOutlet and IBAction?
Model answer
An @IBOutlet is a property that references a UI element designed in Interface Builder (e.g. a label) so code can change it; an @IBAction is a method connected to a UI event (e.g. a button tap) that runs when the event occurs.
8. Differentiate between UIKit and SwiftUI.
Model answer
UIKit (2008) is an imperative framework: you create and update views step by step using view controllers, storyboards and Auto Layout, usually with MVC. SwiftUI (2019) is declarative: you describe the UI as a function of state using views like VStack, Text and Button, and the framework updates it automatically; it offers live previews and works on all Apple platforms (iOS 13+).
9. What is Info.plist?
Model answer
Info.plist (information property list) stores an iOS app's configuration – bundle identifier, version, display name, supported orientations, required capabilities and privacy usage descriptions (e.g. NSCameraUsageDescription) shown when asking for permissions. It is similar to Android's manifest.
10. List the iOS application states.
Model answer
Not running, Inactive (foreground without events), Active (foreground with events), Background (executing code while not visible) and Suspended (in memory but not executing).
11. List the steps to publish an iOS app on the App Store.
Model answer
Enrol in the Apple Developer Program (USD 99/year), create the bundle ID and signing certificates/profiles, archive the app in Xcode, upload the build (IPA) to App Store Connect, optionally beta test with TestFlight, add metadata, screenshots and privacy details, submit for App Review and release after approval.
This lesson ends with a quiz of 39 MCQs. Open the lesson on PrepOasis to take it and save your progress.
Previous: Week 3 Lab 3 – Student Information App: Change Image and Name from Resource and String Folders · Next: Week 4 Lab 4 – Create Two Activities and Move Between Them
All lessons in Mobile Application Development (CDE-315) – BS CS 5th Semester