More in Mobile Dev — page 19
SwiftUI Sheets: State-Driven Modal Overlays
A SwiftUI sheet is a temporary, state-bound overlay that slides over your current view. Use it for focused tasks like composing a message or picking a date. State and environment values do not automatically propagate into its isolated view hierarchy.
TCA: Unidirectional State for SwiftUI
TCA is a strict pipeline for SwiftUI: state and actions enter a pure reducer, emitting new state and effects. Use it when complex flows need reproducible tests without launching the app.
Build Custom Instruments with os_signpost
os_signpost turns code intervals into Instruments graphs by pairing begin-end markers with a visualization package. Use it to correlate app work like model hydration with system CPU and memory metrics. Unmatched begin-end calls break tracks and ruin the view.
Swift Existential Types: The Polymorphism Box
An existential type is a boxed protocol: you see the interface, not the concrete type inside. Use it to store mixed concrete types behind one protocol, like [any Logger]. Prefer generics; existentials hide types and add dynamic dispatch overhead.
Protocol-Oriented Programming in Swift
Protocol-oriented programming swaps inheritance for composable capabilities via protocol extensions. Use it to share behavior across structs without forcing a superclass. The footgun is protocol bloat: indirection without reuse is bureaucracy.
Swift Properties: Accessors in Disguise
A Swift property runs code on every read or write. Use stored properties for state, computed properties for derived values, and observers for side effects. The footgun is heavy work in a computed getter, turning innocent dot syntax into a performance trap.
Swift Closures: Functions with a Memory
A closure is a function carrying luggage: it captures surrounding variables and remembers them later. Use them in SwiftUI actions, async completions, and array transforms. Beware a strong reference cycle from capturing self without a capture list.
Swift Collections: Array, Set, Dictionary
Swift's three collections are different access patterns, not just different APIs. Arrays keep order, Sets enforce uniqueness, and Dictionaries map keys to values. Picking an Array for uniqueness checks turns membership from O(1) into O(n) scans.
Swift Basic Types: Value Semantics by Default
Swift's basic types are value type structs, so assignment copies, not shares, a reference. You feel this when passing Strings into functions or choosing Int over Double. The footgun is treating them as free to copy; large values cost memory and speed.
Apple's Natural Language Framework
Apple's Natural Language Framework turns raw strings into structured meaning on-device without network calls. Tokenize queries or extract entities from user text locally. It is not infallible; heavy synchronous tagging on the main thread freezes your UI.
UserNotifications Framework: iOS Alert Gatekeeper
UserNotifications is the gatekeeper between your app and the lock screen. You use it to request permission and schedule local or push alerts on iOS. Send a notification before authorization and the system silently drops it.
Result Builders: Declarative Swift DSLs
Result builders teach the compiler to fold expressions into one combined value, enabling declarative DSLs. SwiftUI relies on them to compose stacked views. Type errors surface on compiler-generated boilerplate instead of your original code.
Swift Enums: Type-Safe Choice Modeling
A Swift enum is a closed menu of possibilities the compiler tracks exhaustively. Use it to replace string constants or model a network result state. Adding a case without updating every switch breaks compile-time safety if you rely on a default clause.
How would you optimize Flutter CI build times beyond caching?
Tests platform build pipeline knowledge and CI design. Answers hit Gradle parallelism and R8 config for Android, Xcode derived data, target thinning on iOS, plus Dart AOT flags and sharding.
Securely inject secrets for build flavors in CI/CD
WHAT IT TESTS: Secret management and threat modeling for CI/CD build flavors. ANSWER OUTLINE: Contrast CI environment variable injection with runtime secrets-manager fetches via CLI, comparing rotation overhead and blast radius.
Propose a Dart FFI approach to share camera frames and its risks
Tests zero-copy frame sharing via Dart FFI plus ownership and thread hazards. Propose native allocation, pass pointer to Dart as external TypedData, use ring buffer, then free; cite use-after-free and races.
Structure a POST request to send a Dart object as JSON
WHAT IT TESTS: Your grasp of HTTP semantics and Dart serialization. ANSWER OUTLINE: Set Content-Type application/json, serialize to Map via toJson, encode with dart:convert jsonEncode, and pass the string as body.
Design a BLoC solution for an API call that updates multiple UIs
Decoupled BLoC orchestration for multi-surface updates. Use a coordinator stream so each BLoC subscribes independently while keeping loading and error states local per widget. Directly nesting one BLoC inside another or using global variables for shared state.
Riverpod providers are objects, not widgets. What are the practical advantages?
Tests architectural decoupling of state and UI in Flutter. Strong answers hit compile-time safety, unit testing without widget trees, and logic that survives outside BuildContext. Red flag: praising syntax sugar without explaining the coupling problem.
Design an immutable UserSettings class with copyWith for Flutter state
Tests immutability as Flutter's state foundation. A great answer shows final fields, a const constructor, copyWith with nullable named params and null-aware fallback, and explains how immutability prevents accidental shared mutations during rebuilds.