More in Mobile Dev — page 9
Copy-on-write and implementing it for a custom struct
WHAT IT TESTS: value semantics with shared backing storage. OUTLINE: CoW shares a buffer until mutation, deep-copying only when the buffer is non-unique; Array, Dictionary, Set, String use it; implement with a class storage box and isKnownUniquelyReferenced.
map versus compactMap versus flatMap
WHAT IT TESTS: functional transforms on sequences. OUTLINE: map transforms each element one-to-one; compactMap transforms then drops nils; flatMap transforms to sequences then concatenates.
Debugging a closure capture leak in a third-party library
WHAT IT TESTS: methodical leak diagnosis. OUTLINE: use the Memory Graph Debugger to inspect retain paths, the Leaks and Allocations instruments, and malloc stack logging; trace the cycle before patching.
Verifying and avoiding copy-on-write overhead
WHAT IT TESTS: CoW mechanics and mutation patterns. OUTLINE: confirm extra copies via isKnownUniquelyReferenced or instruments and the retain trace; ensure unique references, mutate inout/in place, reserveCapacity, avoid aliasing.
The dynamic keyword and message dispatch
WHAT IT TESTS: dispatch mechanisms and ObjC runtime. OUTLINE: dynamic forces Objective-C message dispatch via objc_msgSend, enabling KVO and swizzling, at the cost of skipping inlining and devirtualization.
dispatch_async versus Task.detached for offloading work
WHAT IT TESTS: GCD versus structured concurrency. OUTLINE: dispatch_async submits a closure to a queue; Task.detached starts an unstructured async task off the current actor without inheriting context.
What an autoreleasepool is and when to add one manually
WHAT IT TESTS: deferred deallocation under tight loops. OUTLINE: an autorelease pool holds objects until it drains; wrap tight loops creating many temporary ObjC objects in autoreleasepool to cap peak memory. RED FLAG: thinking it relates to ARC retain cycles.
Exposing Swift classes to Objective-C
WHAT IT TESTS: Swift-to-ObjC interop rules. OUTLINE: subclass NSObject or mark members @objc, import the generated ModuleName-Swift.h, and accept that Swift-only types like enums with associated values cannot cross.
Struct versus class performance and memory tradeoffs
WHAT IT TESTS: value versus reference semantics and allocation cost. OUTLINE: structs are value types, often stack-allocated with no ARC; classes are heap-allocated reference types with retain counts. RED FLAG: claiming structs are always faster.
Diagnosing choppy scrolling performance
WHAT IT TESTS: profiling discipline over guessing. OUTLINE: reach for Instruments, especially the Time Profiler and Core Animation/Hangs tools, and look for main-thread work and dropped frames. RED FLAG: blindly optimizing without measuring first.
Purpose and setup of an Objective-C bridging header
WHAT IT TESTS: mixed-language project setup. OUTLINE: the bridging header imports ObjC headers into Swift; Xcode auto-creates it or you add it manually and set the build setting. RED FLAG: confusing it with the generated Swift-to-ObjC header.
Privacy manifests and the app privacy report
WHAT IT TESTS: privacy-manifest responsibilities. OUTLINE: PrivacyInfo.xcprivacy declares collected data types, tracking, and reasons for required-reason APIs; Xcode aggregates your manifest plus SDK manifests into a privacy report.
Securely managing signing assets in CI/CD
WHAT IT TESTS: secret handling for CI signing. OUTLINE: keep encrypted certificates and profiles in a controlled store or fastlane match repo, inject the decryption key and credentials via CI secrets, install into a temporary keychain per run.
App Thinning: slicing, bitcode, and on-demand resources
WHAT IT TESTS: download-size optimization mechanisms. OUTLINE: slicing delivers only the assets and code a device needs; bitcode let Apple recompile and re-optimize; on-demand resources defer large assets until requested.
Automatic signing: benefits and limitations on teams
WHAT IT TESTS: managing signing across a team. OUTLINE: automatic signing creates certificates and profiles on demand and keeps them in sync, easing local setup; limits include proliferating certificates, weak CI fit, and less control for complex entitlements.
Phased release to limit update risk
WHAT IT TESTS: risk-managed rollout knowledge. OUTLINE: enable phased release so an approved update reaches a growing percentage of automatic-update users over seven days; pause if metrics spike.
Using dSYM files to symbolicate crash reports
WHAT IT TESTS: crash symbolication knowledge. OUTLINE: a dSYM maps stripped memory addresses back to function names, files, and line numbers; matched by UUID it symbolicates the report to readable frames.
Ad Hoc versus external TestFlight distribution
WHAT IT TESTS: choosing the right beta channel. OUTLINE: ad hoc installs on pre-registered device UDIDs without Apple review; external TestFlight reaches many testers via the app but needs Beta App Review.
Archiving and uploading a build to TestFlight
WHAT IT TESTS: the release-build distribution flow. OUTLINE: select a real-device or Any iOS destination, Product Archive, then in the Organizer distribute to App Store Connect, where the build appears for internal TestFlight testers after processing.
App ID, provisioning profile, and signing certificate
WHAT IT TESTS: the code-signing trust chain. OUTLINE: the certificate proves who you are, the App ID identifies the app and its capabilities, and the provisioning profile binds certificate, App ID, and allowed devices so iOS trusts the install.