iOS (Swift and SwiftUI)¶
Scope: native iPhone and iPad apps written in Swift with SwiftUI, in the Swift 6 language mode. The App Store has required Xcode 26 and the iOS 26 SDK since 28 April 2026 (MOBGAME-5), and the current release is Xcode 27, with Swift 6.4 and the iOS 27 SDK. Most rules also apply to UIKit code and to Apple's other platforms. Store requirements, privacy declarations and purchases for games are in Mobile games. Keeping secrets out of app builds (SEC-11) and encrypting every connection (SEC-13) are in Security, third-party SDKs and personal data in Privacy and personal data, and sign-in in Authentication and sessions. Cross-platform apps are covered in React Native and Expo and Flutter.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
Apple publishes no single architecture guide for iOS apps. Use the framework documentation and the Swift guides below as the baseline, and the key rules for the decisions they leave open.
- 9 OWASP Mobile Application Security Verification Standard (MASVS): the security requirements for mobile apps: storage, cryptography, authentication, network communication, platform interaction, code quality, resilience and privacy. The OWASP MASTG describes how to test each of them on iOS.
- 8 SwiftUI (Apple Developer Documentation), with Model data and Managing model data in your app: the baseline for app structure, views and data flow: scenes, state, bindings, Observation and the environment.
- 8 Concurrency (The Swift Programming Language): asynchronous functions, tasks and task groups, isolation, the main actor, actors and
Sendabletypes. The Swift 6 concurrency migration guide explains data-race safety and how to adopt it in existing code. - 8 Swift API Design Guidelines (Swift.org): naming and API conventions, led by clarity at the point of use, that make your code read like the standard library.
- 8 Human Interface Guidelines (Apple): the design guidance for Apple platforms. For architecture decisions, read Accessibility, which asks for larger text sizes, VoiceOver descriptions and support for other assistive technologies.
- 7 Security (Apple Developer Documentation) and the Apple Platform Security guide: the Keychain, certificate, trust and cryptography APIs, and how the platform protects data on the device, including Data Protection classes.
- 7 SwiftData (Apple Developer Documentation): persistence for Swift model classes, with schema versions and migrations, concurrency and syncing. The Backyard Birds sample app combines it with SwiftUI and Observation.
- 7 Testing (Xcode): Swift Testing for unit tests, XCTest with XCUIAutomation for UI tests, test plans, code coverage and the test pyramid.
Key rules¶
State and data flow¶
- 7
IOS-1Make each shared model an@Observableclass, create it with@State private varin the view orAppthat owns it, and pass it down as a plain property, with@Bindablewhere a subview needs bindings, or through.environment(_:). With Observation, available since iOS 17, a view updates only when a property that itsbodyreads changes, and you use@Stateand@Environmentinstead ofObservableObject,@StateObjectand@EnvironmentObject. (Apple, Managing model data in your app, Migrating from the Observable Object protocol to the Observable macro) - 7
IOS-2Keep data and the logic that changes it in model types, not in views, and use@Stateonly for state that a view owns: declare itprivatein the highest view that needs it, and pass the value or a binding to subviews. Separating the data model from the views makes the app more modular and easier to test. Don't do expensive work in a@Statedefault value, which SwiftUI creates every time it creates the view; defer it to.task. (Apple, Managing model data in your app, State)
Concurrency¶
- 7
IOS-3Build every target in the Swift 6 language mode, which prevents data races at compile time. Migrate older modules one at a time, for example by setting Strict Concurrency Checking to Complete in the Swift 5 mode first and fixing the warnings. (Swift.org, Data race safety, Enable data-race safety checking, Migration strategy) - 7
IOS-4Keep UI code and UI state on the main actor, and add concurrency only where you need it: set Default Actor Isolation toMainActorfor app targets, run heavy work off the main actor with@concurrentfunctions, and keep other mutable state that tasks share in actors. The main actor protects the data that the UI shows, and isolating code to the main actor by default reduces false data-race errors in code that runs sequentially. (The Swift Programming Language, Concurrency, Xcode, Build settings reference, Swift.org, Swift 6.2 released, Apple, Embracing Swift concurrency (WWDC25)) - 6
IOS-5Useasync let, task groups and SwiftUI's.taskmodifier rather than unstructuredTask { }, and when you do create aTask, keep its handle and cancel it when its work is no longer needed. Child tasks are cancelled with their parent, and SwiftUI cancels a.taskwhen its view goes away, but you are responsible for an unstructured task yourself. This is how Swift appliesPRIN-16. (The Swift Programming Language, Concurrency, Apple, task(name:priority:file:line:_:))
Secrets and secure connections¶
- 9
IOS-6Store tokens, passwords and keys in the Keychain with the most restrictive accessibility that works for the app, such askSecAttrAccessibleWhenUnlockedThisDeviceOnly, not inUserDefaults, which stores data on disk unencrypted. Give files that hold personal data thecompleteData Protection class if the app reads them only in the foreground. This is how iOS apps applySEC-19. (Apple, UserDefaults, Restricting keychain item accessibility, Encrypting your app's files) - 9
IOS-7Sign users in throughASWebAuthenticationSession, with the authorization code flow and PKCE (AUTH-2), never in aWKWebView. RFC 8252, the best current practice for OAuth in native apps, says that apps must not use embedded user agents for authorization requests. (IETF, RFC 8252, 8.12 Embedded user agents, Apple, ASWebAuthenticationSession) - 8
IOS-8Keep App Transport Security on: don't setNSAllowsArbitraryLoads, fix a server that fails the ATS checks instead of adding an exception, and limit any exception you can't avoid to the domains that need it. This appliesSEC-13. Exceptions reduce the app's security, and some must be justified in App Review. (Apple, Preventing insecure network connections)
Privacy¶
- 9
IOS-9Add a privacy manifest (PrivacyInfo.xcprivacy) to the app that declares the data it collects and an approved reason for each required reason API it uses, use the SDKs on Apple's list only in versions that include their privacy manifest (and their signature, if you add them as binaries), and compare the privacy report that Xcode generates from all the manifests with the App Store privacy details before each release. App Store Connect doesn't accept apps that use required reason APIs without a declared reason. This appliesMOBGAME-6andPRIV-11to every app. (Apple, Privacy manifest files, Describing use of required reason API, Describing data use in privacy manifests, Third-party SDK requirements)
App lifecycle¶
- 7
IOS-10Save the user's work when the scene phase changes to.background, because the app may be terminated soon after, and restore lightweight UI state, such as the selected tab, with@SceneStorage. Keep model data and sensitive data out of@SceneStorage. (Apple, ScenePhase, SceneStorage) - 6
IOS-11Do background work only through the system's mechanisms: finish a task the user started withbeginBackgroundTask(withName:expirationHandler:), transfer large files with a backgroundURLSession, and schedule refreshes and maintenance asBGAppRefreshTaskandBGProcessingTaskrequests. The system decides when scheduled tasks run, and terminates the app if a task overruns its time. (Apple, Choosing background strategies for your app)
Persistence and networking¶
- 7
IOS-12Persist structured app data with SwiftData, or Core Data, and version the schema from the first release: describe each released schema with aVersionedSchema, and the migrations between them with aSchemaMigrationPlan. This appliesDATA-2to the data on users' devices; Core Data migrations likewise depend on properly versioned models. (Apple, SwiftData, VersionedSchema, SchemaMigrationPlan, Core Data, Staged migrations) - 6
IOS-13Make HTTP requests withURLSessionand its async methods, setwaitsForConnectivityso that a request waits for a network instead of failing at once, and keep the data the user needs offline in local storage. Put timeouts and retries with backoff on every call (OPS-3). (Apple, TN3151: Choosing the right networking API, waitsForConnectivity, SwiftData)
Accessibility¶
- 7
IOS-14Use the built-in text styles, and make any custom font scale the same way, so that text follows Dynamic Type, give every meaningful image and custom control a VoiceOver label, and hide decorative images from VoiceOver. Check each screen with Accessibility Inspector, and in UI tests withperformAccessibilityAudit(for:_:). This appliesA11Y-9andA11Y-12. (Apple, HIG: Typography, HIG: VoiceOver, Performing accessibility audits for your app)
Testing and delivery¶
- 7
IOS-15Write unit tests with Swift Testing and UI tests with XCTest and XCUIAutomation, in a test pyramid (TEST-1), and run them on every pull request withxcodebuild testor Xcode Cloud. (Apple, Testing, Running tests and interpreting results, Xcode Cloud) - 7
IOS-16Sign release builds with cloud-managed certificates, through automatic signing in Xcode or in Xcode Cloud, and never commit exported signing identities or their passwords. If you must sign manually, protect an exported identity with a strong password, share the file and the password through different channels, and keep CI copies in the CI's secret store (SEC-2). (Apple, Distributing your app for beta testing and releases, Cloud-managed certificates, Synchronizing code signing identities with your developer account)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 7 Swift 6 language mode: set the Swift Language Version build setting (
SWIFT_VERSION) to 6, orswift-tools-version: 6.0in a package, and the compiler reports data-race safety violations as errors. In Swift 5 mode, Strict Concurrency Checking set to Complete reports them as warnings. ChecksIOS-3. - 7 App Store Connect upload checks: App Store Connect doesn't accept builds that use required reason APIs without a declared reason, and rejects invalid privacy manifest files and listed SDKs without one. Uploading every build to TestFlight from CI runs these checks. Partly checks
IOS-9. - 7 Accessibility audits in UI tests:
performAccessibilityAudit(for:_:)fails a UI test when the current screen has issues such as missing element descriptions, insufficient contrast, clipped text or text that doesn't support Dynamic Type. Call it on every screen the tests visit. Partly checksIOS-14. - 6 Verifying the origin of your XCFrameworks (Xcode): the build fails if a binary SDK's code signature is removed, becomes invalid, or changes to a different developer. Partly checks
IOS-9. - 6 Thread Sanitizer and Main Thread Checker (Xcode): turn them on for the Test action or in a test plan configuration. They report data races between threads, and system APIs called off the main thread, while the tests run. Partly checks
IOS-3andIOS-4. - 5 SwiftLint opt-in rules:
private_swiftui_stateflags@Stateproperties that aren't private, andaccessibility_label_for_imageandaccessibility_trait_for_buttonflag images without a label that aren't hidden from accessibility, and tappable views without a button or link trait. Partly checksIOS-2andIOS-14.
Tutorials and further reading¶
- 7 Develop in Swift Tutorials (Apple): building apps with Swift, SwiftUI, SwiftData and Swift Testing in Xcode, from the first project onwards.
- 6 Embracing Swift concurrency (Apple, WWDC25): taking an app from single-threaded code to concurrency, and adding concurrency only where it's needed.
- 6 Discover Observation in SwiftUI (Apple, WWDC23): how Observation tracks the properties a view reads, and how
@State,@Environmentand@Bindablework with it. - 6 Reducing your app's size (Apple): measuring download and install sizes with an app size report and App Store Connect, and optimizing assets and settings.