More in Mobile Dev — page 44

Metro: The JavaScript Bundler for React Native
Metro bundles your React Native app's JavaScript, finding all modules, transpiling them for the device, and merging them into one file. It's what powers `npx react-native start`.
Flexbox: Responsive Layouts in React Native
Flexbox arranges components along a primary axis, creating responsive UIs without manual calculations. It's used for nearly all layout needs, from centering items to building complex grids.
Styling in React Native with StyleSheet
StyleSheet is React Native's answer to CSS, defining styles in JavaScript to separate presentation from logic. Use `StyleSheet.create()` to define reusable style objects that get static type checking. The footgun is styling inline, which hurts performance.
React Native Core Components: Your UI Building Blocks
Think of Core Components as React Native's built-in LEGO bricks for UIs, translating your code into native Android and iOS views. Use them for layouts (`View`), text (`Text`), and lists (`FlatList`). The footgun: never use `ScrollView` for long lists.
The Package.swift Manifest File
Think of Package.swift as a recipe for your code, telling the Swift Package Manager (SPM) what to build, what it needs, and where it can run. You use it to define libraries, list dependencies, and set minimum OS versions.
Swift Property Wrappers: Reusable Logic for Properties
A Swift Property Wrapper is a template for a property's get/set logic, letting you reuse behaviors like data validation without boilerplate. It powers SwiftUI's @State and is great for managing UserDefaults.

Refining Objective-C APIs for Swift with NS_SWIFT_NAME
NS_SWIFT_NAME gives Objective-C code a Swifty alias without changing the original API. Use it to modernize legacy frameworks by removing prefixes for Swift consumption.

Optimizing iOS App Launch Time
An app launch is a race against the system's watchdog timer. The OS loads your app in two phases: pre-main and main. Optimizing both is key. The biggest footgun is ignoring the pre-main phase, where bloated dynamic libraries can kill performance.

Address Sanitizer: Find Memory Bugs at Runtime
Address Sanitizer (ASan) is a runtime debugging tool that finds memory corruption bugs. Enable it in Xcode to catch buffer overflows and use-after-free errors as they happen, preventing crashes that are hard to trace back to their source.
Swift Errors and the NSError Bridge
Swift's modern `Error` protocol and Objective-C's `NSError` are different, but Swift automatically "bridges" them. This is key when calling older Apple APIs, which throw `NSError`s.

Lightweight Generics: Type Safety for Objective-C
Lightweight generics bolt type safety onto Objective-C collections like NSArray. This lets Swift see an NSArray<NSString *> as a type-safe [String] instead of [Any], preventing runtime crashes.

Objective-C Nullability: Bridging to Swift's Optionals
Nullability annotations are like adding `?` or `!` to your Objective-C pointers, telling Swift how to handle `nil`. They're essential in mixed codebases to bridge Objective-C's pointers to Swift's safe Optionals.
Autorelease Pools: Managing Temporary Object Memory
Think of an autorelease pool as a temporary holding pen for objects. It defers their deallocation until a code block ends. UI frameworks handle this, but you'll add one in tight loops with many temporary objects to reduce peak memory, or on background threads.

Selectors: Objective-C's Function Pointers in Swift
A selector is a lightweight name for a method, not a direct pointer. Swift uses it to call Objective-C code dynamically at runtime. It's common in UIKit for target-action patterns, like button taps. The footgun: forgetting `@objc` causes a runtime crash.

Bridging Header: Mixing Objective-C and Swift
A bridging header is a translation list for Xcode, letting your new Swift code call old Objective-C code. It's essential when migrating a legacy codebase or using an Objective-C library. The footgun: it only exposes Objective-C to Swift, not vice-versa.

Main Thread Checker: Keep Your UI Responsive
The Main Thread Checker is an Xcode tool that catches UI updates on background threads, which cause crashes or glitches. It runs during debugging, flagging AppKit, UIKit, or SwiftUI calls made off the main thread.

Grand Central Dispatch (GCD): Your App's Task Manager
Grand Central Dispatch (GCD) is your app's task manager, letting you run code in the background without freezing the UI. Use it to offload network requests or heavy computations, then update the UI on the main queue.

macOS App Notarization: Apple's Security Checkpoint
Notarization is an automated security screening for macOS apps. You upload your app, Apple scans it for malware, and issues a ticket to attach to it. This is mandatory for apps distributed outside the Mac App Store.

App Store Server Notifications: Your Backend's Source of Truth
App Store Server Notifications are webhooks from Apple that tell your backend about subscription events like renewals or refunds. They are your server's source of truth for user entitlements, letting you grant or revoke access without relying on the client…

On-Demand Resources: Keep Your App Bundle Slim
On-Demand Resources (ODR) host app assets on the App Store, not in your bundle, shrinking your initial download. Use it for game levels or tutorials not needed at first launch. The OS downloads assets by "tag" when requested, but can also purge them to save.