The short answeriOS does what Android does: a sandbox, a lifecycle, permissions. Apple holds the keys: only code Apple has authorized runs, and every door is Apple's. Without a purpose string, the app usually crashes. An app the user leaves is frozen within seconds.
The film
Film coming soon
Same shape as Android, other keys
Three rows are the same idea, renamed. Three decide who holds the keys.
| Android What happens when you tap an app's icon? | iOS | |
|---|---|---|
| The package | An APK | An .app bundle, in an .ipa |
| The contract | AndroidManifest.xml | Info.plist, plus entitlements: what Apple granted |
| The sandbox | A Linux user per app | A container per app |
| The certificate | Self-signed, no authority | Issued by Apple |
| The way in | Play, or an APK the user allows | Apple's doors only |
| Work after leaving | A declared foreground service, with a notification | A declared mode, or handed to iOS |
On Android, no authority vouches for your certificate. On an iPhone, nothing runs unless Apple authorized it.
Go deeper Inside the signature 1 min
Before anything runs, iOS checks the code signature. It is a hash of every file, signed with a certificate Apple issued to a named developer. Change one byte, and iOS will not launch the app. This covers every file shipped in the bundle, native code and bundled JavaScript alike. JavaScript an app downloads later, such as an Expo update, is not signed by Apple; the store's rules limit what it may change.
The signature carries the app's entitlements: the capabilities Apple granted, such as push notifications or iCloud. A provisioning profile ties it all together: who may sign, which app, on which devices, until when, with which entitlements. The App Store checks that signature and the profile, then re-signs the app as it distributes it: the copy on a user's iPhone carries no profile.
On Android, the certificate is self-signed: no authority stands behind it. On Google Play, Google keeps the app's signing key and signs what it delivers.
Go deeper Files and secrets 1 min
At install, iOS creates a container for the app: a folder with a random name, holding Documents/, Library/ and tmp/. The app reads and writes there, and reaches anything else only through the system: the share sheet, the document picker, iCloud. Unlike Android, iOS gives no app a user of its own: every app runs as the same user, mobile, and the sandbox, not the user, keeps each one in its container.
Files in the container are encrypted by default once the user has set a passcode, and readable from the first unlock after a restart. UserDefaults is for settings, not secrets: it adds no encryption of its own, and goes into the device's backups. Secrets belong in the keychain, by default readable only while the device is unlocked.
Every door is Apple's
iOS runs only code Apple has authorized. So every way onto an iPhone is a way Apple provides.
- The App Store, after App Review.
- TestFlight, for testers you invite.
- Your own devices, from Xcode.
- A company's staff, employees only.
In the European Union, Japan and Brazil, a law or a regulator added other doors. The fold below lists them.
An iPhone has no “Install unknown apps” setting. Apple is the doorman at every door.
Go deeper Where a law or a regulator opened other doors 1 min
In the European Union, a law brought alternative app marketplaces in iOS 17.4, and a developer's own website in iOS 17.5. In Japan, a law brought marketplaces in iOS 26.2. In Brazil, an agreement with the competition regulator brought them in iOS 26.5. In Japan and Brazil, only marketplaces install from a website.
These apps skip the App Store, not Apple. Each one is notarized: a baseline review by Apple of security and privacy, whatever the channel. There, Settings lets the user allow a marketplace or a developer's website: only ones Apple authorized, with notarized apps.
TestFlight takes up to 10,000 testers, invited by email or by a public link, each build for 90 days; the first build for outside testers is reviewed. Your own devices take a build from Xcode; with a free Apple Account, it runs for seven days, on up to three devices, three apps each.
Checkpoint
A classmate sends you their app's .ipa file. Can you install it on your iPhone by opening the file?
See the answer
iOS has no setting to install unknown apps. An app arrives through the App Store or TestFlight, or as a build whose profile lists your device. The developer's signature alone is not enough.
No purpose string, a crash
The first use of the camera shows a dialog. iOS draws it, not your app, and quotes your purpose string: the line in Info.plist that says why. Without that line, the request fails.
- The app asks for the camera. iOS shows its own dialog, with the app's name and its purpose string.
- The user allows or refuses. iOS stores the answer in Settings, and does not ask again.
- No purpose string: the request fails, and the app crashes at that moment.
Forget the declaration, and Android quietly says no. Forget the purpose string, and iOS usually crashes the app.
Go deeper The user's answer, notifications, review, privacy labels 1 min
Declaring is not granting. As with Android's manifest, the purpose string only lets the app ask: the user still decides, once, and can change the answer in Settings. The app must keep working when the answer is no.
The camera, the microphone, the location, the photos and the contacts are protected resources, among others. Notifications ask for permission too, but need no purpose string.
App Review rejects a build whose code reaches a protected resource without a purpose string, even when only a library calls the API. The App Store listing shows what data the app collects. Since May 2024, a privacy manifest must also say why the app uses certain APIs that could fingerprint a device, UserDefaults among them: self-declared, and the developer answers for it.
Leave the app, and it freezes
Leave: the app gets a few seconds. Then iOS suspends it, running nothing. Low on memory, iOS terminates it, without a callback.
- Not runningnever launched, or terminated
- Inactivea passage between states
- Activein front, interactive
- Backgrounda few seconds to finish
- Suspendedfrozen in memory, no CPU
- Terminatedno callback; back to not running
From suspended: instant. From terminated: a cold launch.
Save as the app leaves the foreground. A swipe up in the App Switcher, the screen of recent apps, leaves only stored data.
Go deeper Two kills, and what survives each 1 min
Two kills. The termination above is the system's: the user never closed the app, so iOS keeps each scene's saved state, a small summary of the screen the app was on and the text you typed. A native app that restores it reopens where the user left it. A swipe up in the App Switcher is the user closing the app: iOS deletes that state and cancels the app's background transfers. Only what the app stored comes back, so the draft belongs in a file or a database.
What survives what, from Apple's documentation:
| Kept in | The system's kill | Swipe up |
|---|---|---|
Memory: @State, a view model | lost | lost |
Saved state: state restoration, @SceneStorage | kept | lost |
Storage: a file, UserDefaults, a database | kept | kept |
Side by side, the two kills differ in one place. Memory is lost both times; the saved state survives the system's kill, but not a swipe up; a file survives both.
In Expo, Ionic and a PWA, the JavaScript keeps its state in memory, so both kills look the same: the JavaScript starts over, and only storage comes back, such as AsyncStorage, Capacitor Preferences or IndexedDB.
The App Switcher shows a snapshot of each recent app, suspended or already terminated. Swiping them up saves no battery: a suspended app runs nothing, and Apple advises the swipe only for an app that does not respond.
Go deeper Background modes, and Android 1 min
Work that must go on after the user leaves needs a background mode the app declares and App Review checks: audio, location, voice over IP, fetch and processing jobs the system schedules, pushes that wake the app briefly. Or it is handed to the system: a background URLSession transfers files even while the app is suspended, or terminated by the system, but not after a swipe up in the App Switcher. Since iOS 26, an app can also ask to finish one job the user started, visibly and cancellably. A general “keep running” does not exist.
Android now freezes too: since Android 14, on phones that support it, a cached process is frozen about ten seconds after it becomes cached. The difference is the way out: on Android, a foreground service, declared with its type and shown as a notification, keeps the app running. On iOS, nothing general does.
Four builds, one iOS
| Build | Rotation | The system's kill | Save by |
|---|---|---|---|
| Native | Keeps its screen | Back from its saved state | scenePhase: inactive |
| Expo | Keeps its screen | Starts over | AppState: inactive |
| Ionic | Keeps its screen | Starts over | App plugin: appStateChange |
| Web app (PWA) | Keeps its screen | Starts over | As the user types; visibilitychange: hidden |
After the system's kill, a native app can return to the same screen from its saved state, a summary iOS keeps, if it saved one. The JavaScript builds, Expo, Ionic and the web app, start over: their memory is gone; only what they saved returns.
Rotation keeps the screen. A termination keeps only what you saved.
Go deeper The same moments, in each framework 1 min
Where to save: scenePhase .inactive then .background in SwiftUI; sceneWillResignActive then sceneDidEnterBackground in UIKit; AppState “inactive” then “background” in React Native; the App plugin's appStateChange, then pause, in Capacitor; in a web app, as the user types, then the visibilitychange event. After the kill, Expo runs its JavaScript bundle again, the WebView reloads an Ionic app, and Safari's engine reloads the page. Since iOS 13, these states belong to each scene, each window of the app; since iOS 27, an app built with the latest SDK must use scenes, or it does not launch.
A rotation calls none of them. UIKit keeps the view controller and tells it the new size, through viewWillTransition(to:with:); SwiftUI keeps each view's @State and lays the views out again. So on an iPhone, the rotate test checks only the layout, whatever the build. Unless the code shows a different view in landscape: that view starts with fresh state.
Checkpoint
Your Expo app shows a half-typed note. The user turns the iPhone, then later swipes the app up in the App Switcher and reopens it. What is left of the note?
See the answer
A rotation keeps the screen and its memory, on every build. A swipe up in the App Switcher ends the app: the JavaScript starts over, and only storage, such as AsyncStorage, brings the note back.
Before the lab
Seeing it needs no Mac; building it does
Xcode and the iOS simulators run only on macOS. To build an iOS app, you need a Mac: yours, or one in the cloud. To see your app on an iPhone, you may not.
| Family | See it on an iPhone, no Mac | Build it for the App Store |
|---|---|---|
| Native, Swift | No | A Mac with Xcode, yours or one in the cloud |
| Expo | Yes: Expo Go, within its limits | EAS Build, on Expo's Macs |
| Ionic + Capacitor | The web build in Safari, without the native shell | A Mac with Xcode, yours or one in the cloud |
| PWA | Yes: Safari opens it, within Safari's limits | No build: it is a website |
To build for the App Store, the certificate and the profile must be yours: a paid Apple Developer Program membership.
In this course’s labs, the native builds are Android’s: Java in Lab 1, then Kotlin and Compose in Lab 2. With an iPhone and no Mac, you run the Expo build in Expo Go, and the PWA in Safari. Your own build on your iPhone needs a paid membership, or a Mac with a free Apple Account, for seven days at a time.
Go deeper Expo Go's limits, Safari's, and the cloud 2 min
Expo Go comes from the App Store. It runs your project only on the same SDK version, only with the native libraries it ships, and only when the CLI and the app are logged in to the same Expo account. Anything else needs a development build.
Safari's limits. On an iPhone, every browser runs web pages in WebKit, Safari's engine; only in the EU and Japan may a browser bring its own. A PWA installs by hand, from Safari's Share menu, behind the ••• button in the Compact layout: Add to Home Screen. There is no WebAPK, and only an installed web app may ask to send notifications. In a Safari tab, a site's stored data is deleted after seven days of Safari use with no interaction on the site.
EAS Build and Codemagic build on their Macs and hand you the signed .ipa. Xcode Cloud too, but you first set it up from Xcode, on a Mac. The membership costs 99 USD a year; an accredited school can ask Apple for a fee waiver. One exception to the Mac: Swift Playground on an iPad builds a SwiftUI app and can send it to App Store Connect.
With knowledge · in class
The AI gets the paperwork wrong
An assistant writes Swift as fluently as Kotlin. It gets the paperwork wrong. It forgets the purpose string, and switches on background modes you did not ask for.
The rule
Save the draft to a file as the user types: it survives the system's kill and the swipe up.
What comes back after a kill is not luck: whoever builds the app decides it, in advance. Decide first what the user finds after the system's kill, the same screen or the first screen with the draft, then tell the assistant.
Paste first, whatever the family
assume iOS can freeze the app seconds after the user leaves and terminate it without warning: save the draft as the user edits it and again as the app leaves the foreground, restore it on a cold launch, enable no background mode unless I ask, and tell me where each piece of state is saved
All families
Say it in the prompt
for every protected resource the app uses, add its iOS purpose string with a one-sentence reason a user would accept, and tell me in which file or setting you put it
Where the purpose strings live
- Native: the target's Signing & Capabilities and Info panes. A new SwiftUI project has no
Info.plistfile. - Expo:
app.json, inios.infoPlistor a module's config plugin. - Ionic:
ios/App/App/Info.plist, a real file afternpx cap add ios. - PWA: nothing to declare. Safari asks the user for you.
Native
Say it in the prompt
for every protected resource the app uses, add its usage description (in Info.plist, or as an INFOPLIST_KEY_ build setting if the project has no Info.plist file) with a one-sentence reason a user would accept; store the session token in the Keychain, never in UserDefaults
State: keep the screen's small state in @SceneStorage, and write the draft to a file as the user types and when scenePhase leaves .active After a swipe up in the App Switcher, only the file comes back.
Check the project
Expo
Say it in the prompt
set each iOS purpose string through the module's config plugin or ios.infoPlist in app.json, with a one-sentence reason a user would accept; store the session token with expo-secure-store
Check the project
Ionic
Say it in the prompt
after npx cap add ios, add to ios/App/App/Info.plist the usage description each plugin's documentation lists, with a one-sentence reason a user would accept
Check the project
PWA
Say it in the prompt
ask for the camera only when the user taps a button that needs it, and keep every other feature working when the answer is no
Check the project
Review reads these settings too. Guideline 2.5.4: background services only for their intended purposes, such as VoIP, audio, location, task completion and local notifications. Guideline 5.1.1: ask only for data relevant to the app's core functionality.
With knowledge · in class
Test both kills on an iPhone
An iPhone has two kills too: test both, as in chapter 03. Any iPhone runs the swipe up, yours or a classmate’s. The system’s kill takes a Mac, or a permission switched off.
-
Swipe up. Any iPhone Open the App Switcher, swipe the app up, then open it: it starts from its first screen, and only what you stored, the draft, comes back. Expo Go, Safari and a Home Screen web app close the same way.
Saved state lostStored data kept
-
The system's kill. With a Mac Run the app from Xcode, go Home, stop it in Xcode, then run it again from Xcode: a native app restores the state it saved, and the draft is still there. Without a Mac Leave an app you allowed to use the camera, switch that access off in Settings, then reopen it. iOS terminated it, Apple's engineers explain, because a running app cannot lose an access. It was not a swipe up, so a native app that saved its state should come back where it was. As on Android, revoking a permission is a kill test too.
Saved state keptStored data kept
- In Expo, Ionic and a PWA, both kills look alike: the JavaScript starts over, and only storage returns. A native Swift app is where they differ.
- Quitting apps does not save battery, Apple's guide says: iOS manages the background itself. Users close apps from the App Switcher anyway, so your app will meet this kill.
An upload that must finish after the user leaves needs a decision of its own, in a later chapter. Do not test it with a swipe up in the App Switcher: that cancels background transfers, and leaving the app does not.
Try it on your phone · 10 minutes
See the sandbox and the kill, no Mac needed
On any iPhone. Each path follows Apple's own guide, linked. No iPhone? Pair with a classmate, or open the fold just below.
No iPhone? The same places on your Android phone 5 min
Open the guide linked in each step: Apple's pages show the iPhone's screens. Then look for the same places on your own phone.
The same answer in Settings. Settings → Apps → Chrome → Permissions → Camera: one answer per app, kept by the system, as on an iPhone. This shows the shape both systems share.
The side door. Settings → Apps → Special app access → Install unknown apps: Android lets you allow an app, such as Chrome, to install others. An iPhone has no such screen. This shows Apple's keys, from the other side.
The rest is on this page. The two simulators above run the purpose string and the freeze: they are your iPhone for this chapter.
-
The answer lives in Settings. Settings → Privacy & Security → Camera.
You should see The apps that asked for the camera, each with its own switch. Apps that never asked are not listed. iPhone User Guide
This proves The answer belongs to the user and the system, not to the app.
-
The bundle and the container. Settings → General → iPhone Storage → an app.
You should see Its storage in detail, then two actions: offload the app, or delete it. Offloading frees the app's storage but keeps its documents and data. Apple Support
This proves The app and its data are two things: the bundle, and its container.
-
The containers you cannot see. Files → Browse → On My iPhone.
You should see A folder only for the apps that chose to share their
Documentsfolder with you. Apple SupportThis shows Every other container stays closed, even to the phone's owner.
-
Leave, then quit. Settings → General → About. Go Home, then reopen Settings. Then open the App Switcher, swipe Settings up, and open it again.
You should see After Home, About is still there. After the swipe up, Settings opens on its first page. iPhone User Guide
This shows Leaving freezes an app where it is. A swipe up ends it, and its screen with it.
Try Clock's Stopwatch too: start it, quit Clock the same way, and reopen it. If it is still counting, the count did not depend on Clock staying open: a stopwatch can be stored as the time it started.
Go deeper Two more places, and homework 2 min
Who works in the background. Settings → Battery → View All Battery Usage, then a day, then an app: its time “On screen” and, if any, “Background”. Background time is work iOS allowed, such as directions, music or mail; a suspended app runs nothing. So quitting apps you are not using does not prolong battery life, Apple says: close an app from the App Switcher only when it stops responding. iPhone User Guide
Settings → General → VPN & Device Management. A company's own app, installed by hand outside the App Store, opens only once the user trusts its developer here. Apple Support
Homework. Settings → Privacy & Security → App Privacy Report: turn it on for a week. It shows when each app accessed data or sensors, and which domains it contacted. Apple Support
Quick check
Android On Android, your notes app is cached, and memory runs short. What runs in your code before the process dies?
See the answer
A killed process runs nothing, not even onDestroy. iOS does the same to a suspended app: it terminates it with no callback, so on both you save on the way out, not at the end.
Android Who vouches for the certificate that signs an app, on Android and on iOS?
See the answer
An Android certificate is self-signed, from a key the developer generates; on iOS, nothing runs unless Apple issued the certificate to a named developer. Play App Signing means Google keeps a key, not that it vouches for one.
The first time your app asks for the camera, a dialog appears. Who draws it, and whose sentence does it show?
See the answer
iOS draws the dialog, not your app, with your app's name and the purpose string it declares. Apple writes no default sentence: without that string, the request fails and the app usually crashes.
Your app's own code is uploading a file, at 40%, when the user switches to another app for twenty minutes. The app declares no background mode. When the user comes back, the upload…
See the answer
Without a declared mode, the app gets a few seconds and is then suspended, upload included; if memory ran short meanwhile, iOS terminated it with no callback. An upload that must finish after the user leaves needs a decision of its own: iOS can carry it on for the app, but not after a swipe up in the App Switcher.
Your SwiftUI app shows a half-filled form, and the user turns the iPhone. What does iOS do with the screen?
See the answer
Rotation is not on iOS's lifecycle: the same screen, in the same process, gets a new size. Android rebuilds a native activity by default; iOS never does. On an iPhone, the rotate test checks the layout.
Your iOS app will use the camera. Which line belongs in your prompt to the assistant?
See the answer
Without a purpose string, the camera request fails and the app usually crashes. Background modes are what assistants switch on unasked, and the camera is asked for when the user taps the button that needs it, not at launch.
In Expo Go, your app opens the camera without a problem. Are your own purpose strings right?
See the answer
In Expo Go, your project runs inside Expo Go's app, with Expo Go's purpose strings: Settings shows Expo Go. Yours ship only in a native build, such as eas build, so test the camera there; android.permissions is Android's list anyway.
A native app remembers the open note with @SceneStorage. It reopens on that note after iOS terminates it, but not after a swipe up in the App Switcher. Why?
See the answer
iOS keeps a scene's saved state after its own termination, because the user expects to come back. When the user closes the app from the App Switcher, iOS deletes that state and cancels its background transfers. The container stays: files and UserDefaults survive both kills. So keep the draft in storage, and test with a swipe up.
Settings → General → iPhone Storage → an app → Offload App. What happens?
See the answer
Offloading frees the app's own storage but keeps its documents and data; deleting would remove both. The app and its data are two things: the bundle, and its container.
You have no Mac, and your lab is the Expo app. How can you see it running on your iPhone?
See the answer
Expo Go, an App Store app, runs your project when it uses the same SDK and only the native libraries Expo Go ships. The simulator runs only on macOS, and a build for the App Store can come from Expo's Macs, with EAS Build.
Recap
- Same shape as Android. Apple holds the keys.
- Every door is Apple's. Nothing runs unless Apple authorized it.
- A purpose string, or a crash. Then the user decides.
- Frozen, then killed without a word. Memory is lost; the saved state, the screen's summary, survives only iOS's kill, not a swipe up in the App Switcher, the recent apps; the file survives both.
- Four builds, one iOS. Rotation keeps the screen; a kill, only what you saved.
- A Mac to build. Expo Go and Safari show it without one.
Sources
- Managing your app's life cycle, Extending your app's background execution time, five seconds, then suspended, Downloading files in the background, a transfer that goes on while the app is suspended, and Transitioning to the UIKit scene-based life cycle, scenes required since iOS 27.
- application(_:didDiscardSceneSessions:), what a swipe up discards and what memory reclamation keeps; UISceneSession, the session destroyed when the user closes the scene in the App Switcher; Restoring your app's state and SceneStorage, the saved state deleted after a force quit, and Apple's test from Xcode; URLSessionConfiguration.background(withIdentifier:), transfers cancelled by a force quit; Quit and reopen an app and Close an app on your iPhone, the gesture, and no battery saved; Apple Developer Forums: changing the camera permission terminates the app, “expected behaviour”, an Apple engineer's answer; Apple Developer Forums: a changed authorization setting terminates the app, why, another Apple engineer's answer (January 2026).
- React Native: AppState and Capacitor: App, the moment to save in each framework; WebKit: the seven-day cap and WebKit: Web Push for web apps, a PWA on an iPhone.
- Requesting access to protected resources, the dialog and the crash, Requesting authorization to capture and save media, for the camera: without the key, the system terminates the app, Managing your app's information property list, why a new SwiftUI project has no
Info.plistfile, and Describing use of required reason API, the privacy manifest and its deadline. - TN3125: Inside code signing, provisioning profiles, Entitlements, Apple Platform Security: runtime process, every app as the user mobile, and AOSP: Application signing, self-signed certificates on Android.
- Encrypting your app's files and Restricting keychain item accessibility, the defaults, and UserDefaults, not for secrets.
- TestFlight overview, About your developer account, the free account's seven days, App Store Review Guidelines, 2.5.4, 2.5.6 and 5.1.1, Web distribution in the EU, Changes to iOS in Japan, and alternative distribution by region, Brazil included, and Changes to iOS in Brazil, the agreement with the regulator CADE, and Installing apps through alternative app distribution, what Settings lets the user allow.
- BGContinuedProcessingTask, iOS 26's visible job, and AOSP: Cached apps freezer and Android 14: foreground service types are required, the Android side of the comparison.
- Apple Developer Program: enrollment, the fee and its waiver, Configuring your first Xcode Cloud workflow, Expo: EAS Build, Expo Go: login now required, Expo: development builds FAQ, Expo: permissions, Expo: internal distribution, a paid account to install your own build, Capacitor: iOS configuration, and Capacitor: Camera, three usage descriptions.
