Skip to main content

Swift engineer system design interview questions

10 questions on system design for swift engineer candidates. Expect prompts such as “Design the architecture of an Instagram-style photo feed for iOS” and “Design an offline-first notes app with cloud sync”, each with a worked answer outline and the follow-ups interviewers push on.

Questions

Showing 1 to 10 of 10 system design questions.

As asked

Design the full iOS client-side architecture for a photo feed that loads images lazily, supports pull-to-refresh, infinite scroll, offline caching, and maintains scroll position after backgrounding. Walk me through every layer.

Sample answer outline

A strong answer covers: UICollectionView with diffable data source for the list, a ViewModel layer (ObservableObject or @Observable) holding paginated posts, a repository abstraction backed by an in-memory cache plus SQLite (via Core Data or GRDB) for offline, a URLSession-based image fetcher with disk and memory NSCache layers, prefetching via UICollectionViewDataSourcePrefetching, and saving scroll offset to scene state restoration. Should mention image decoding off the main thread.

Expect these follow-ups

  • How would you handle conflicting cached data when the same post appears in multiple feeds?
  • What changes when the feed must also support video cells that autoplay on scroll?
system-designiosarchitectureuicollectionviewcaching

As asked

Design the data and sync layer for a notes app that must work fully offline, sync to iCloud or a custom backend when connectivity returns, and resolve conflicts when the same note is edited on two devices.

Sample answer outline

A strong answer describes a local-first architecture: Core Data or SQLite as the source of truth, all writes go local immediately, a sync engine that batches changes and uploads deltas tagged with vector clocks or server timestamps, and a conflict resolution policy (last-write-wins, CRDT merge, or user-prompted). Candidate should mention CloudKit's native CKRecord versioning as an alternative, NSPersistentCloudKitContainer shortcut, and the need for a reliable change feed (NSManagedObjectContext save notifications).

Expect these follow-ups

  • How does CloudKit handle conflict resolution differently from a custom backend?
  • What happens to the sync queue if the user is offline for two weeks on one device?
system-designoffline-firstsynccore-datacloudkit

As asked

Design the end-to-end push notification delivery for a chat app, from the server detecting a new message to the user seeing a notification banner. Cover APNs integration, background processing, notification content extensions, and handling notifications when the app is foreground versus background.

Sample answer outline

A strong answer covers: device token registration and storage server-side, server sending APNs HTTP/2 push with collapseIdentifier for flooding control, iOS receiving the payload and calling UNUserNotificationCenter delegate, background content-available:1 pushes for silent updates, UNNotificationServiceExtension for decrypting end-to-end content before display, and UNNotificationContentExtension for rich previews. Foreground handling: userNotificationCenter(_:willPresent:) decides show-or-not.

Expect these follow-ups

  • How do you handle notification grouping (thread identifiers) for a user who belongs to many chat rooms?
  • What happens when APNs marks a device token as invalid and how do you clean up stale tokens?
push-notificationsapnsiossystem-designnetworking

As asked

Design the location sharing feature for a ride-hailing or family-sharing app. The map must update another user's pin in near real-time (under 3 seconds), the feature must work in the background, and it must be battery-efficient.

Sample answer outline

A strong answer covers: CLLocationManager with significant-change mode for background (lower accuracy but low power), standard updates when app is foreground, delta updates sent to backend via WebSocket or HTTP POST with adaptive interval based on speed, server fan-out via SSE or WebSocket to receivers, MapKit annotation clustering for many users, and battery strategy (increase interval when stationary, reduce when speed exceeds threshold). Background location entitlement and Info.plist key required.

Expect these follow-ups

  • How does the iOS Background Task framework differ from background location for keeping the update loop alive?
  • What privacy prompts must you show and when, per App Store guidelines?
locationcllocationmanagersystem-designbackgroundbattery

As asked

Design a feature flag system that allows gradual rollout of new iOS features, A/B testing, kill switches for broken features, and works without requiring an app store update.

Sample answer outline

A strong answer covers: a remote config service (Firebase Remote Config or custom endpoint) fetched on launch and cached locally, typed flag definitions (enum or struct) that fall back to static defaults in the binary, user-stable bucketing (hash of user ID for consistent assignment), flag evaluation at the call site rather than on a notification so the UI never mid-session changes, and analytics events that record which flag variant each user is in. Kill switches: a flag set to false remotely disables the feature instantly on next launch.

Expect these follow-ups

  • How do you prevent a flag change from causing a visible UI flash mid-session?
  • What is the difference between a kill switch and a gradual rollout and how does bucketing differ between them?
feature-flagsa-b-testingsystem-designiosremote-config

As asked

Design the StoreKit purchase flow for a subscription iOS app: from presenting products to the user, through completing a purchase, to validating the receipt on your server and unlocking content. What are the failure and fraud vectors?

Sample answer outline

A strong answer covers: SKProductsRequest to fetch products, present in-app UI, initiate purchase via SKPaymentQueue.add, listen for SKPaymentTransactionStatePurchased, finish the transaction only after server validation, send the App Store receipt to your backend which calls Apple's verifyReceipt or uses App Store Server Notifications for renewals, and unlock the entitlement in your database. Fraud vectors: receipt replay attacks (validate transaction IDs server-side), jail-broken receipt swapping, and restoring purchases cross-account. StoreKit 2 improves this with signed JWTs.

Expect these follow-ups

  • How does StoreKit 2 (iOS 15) change the receipt model and what is a SignedTransaction?
  • What App Store Server Notification types do you handle for subscription lifecycle management?
storekitiapsystem-designsecuritysubscriptions

As asked

Your iOS app caches product catalog data locally (100k records). The backend can update any record at any time. Design a cache invalidation strategy that keeps the app responsive, stays under 50 MB local storage, and keeps data fresh within five minutes.

Sample answer outline

A strong answer considers: ETag or Last-Modified headers for conditional GETs, a background fetch or push-driven invalidation approach, polling on app foreground with If-None-Match to reduce data transfer, storing only a subset of high-affinity records on disk (GRDB or Core Data with a capped fetch limit evicting LRU records), and using NSPurgeableData or NSCache for the hot in-memory layer. Five-minute freshness with background fetch registration.

Expect these follow-ups

  • How would you invalidate only the changed records instead of the entire catalog?
  • What is the risk of storing 100k records in Core Data and how do you mitigate it?
cachingsystem-designiosnetworkingcore-data

As asked

Design the buffer management and playback architecture for a short-form video feed (TikTok-like) on iOS where the next video should start instantly and playback must handle spotty connectivity gracefully.

Sample answer outline

A strong answer uses AVPlayer with AVPlayerItem for playback, an AVQueuePlayer or a pool of pre-warmed AVPlayerItems for the adjacent visible cells, HLS streaming with AVAssetResourceLoaderDelegate or AVAssetDownloadURLSession for segment caching, pausing buffering for cells more than two positions away, and a fallback thumbnail while buffering. NWPathMonitor tracks connectivity changes to pause or degrade quality. Candidate should mention AVPlayer's automaticallyWaitsToMinimizeStalling.

Expect these follow-ups

  • How do you preload the next video's first few seconds without burning the user's data?
  • What instrumentation would you add to measure actual playback start time in production?
avfoundationvideosystem-designperformancenetworking

As asked

Design the data model and refresh strategy for a WidgetKit home screen widget that shows a user's daily step count. The widget must show fresh data within five minutes of a workout ending, work without draining the battery, and degrade gracefully when the app has not been opened in days.

Sample answer outline

A strong answer covers: WidgetKit's Timeline model where the app extension returns TimelineEntry values and a reload policy, using HealthKit background delivery to wake the containing app on new step data, the containing app then calling WidgetCenter.shared.reloadTimelines to invalidate the widget, storing the latest value in an App Group shared UserDefaults so the widget extension can read it without launching the full app, and a fallback timeline that shows stale data with a timestamp when no fresh data is available. Battery: avoid polling, rely on push-style HealthKit delivery.

Expect these follow-ups

  • What is the difference between TimelineReloadPolicy.atEnd and .after(date)?
  • How do you share Core Data between the main app target and the widget extension target?
widgetkitsystem-designioshealthkitapp-groups