More in iOS & Swift — page 11

XCTest: Apple's Built-in Testing Framework
XCTest is your built-in toolbox for writing unit, performance, and UI tests in Xcode. Use it to verify individual functions or simulate user interactions. A common footgun is writing tests that depend on each other; they must be independent to be reliable.

AVCaptureSession
AVCaptureSession is the central coordinator in AVFoundation that connects camera and microphone inputs to outputs like a preview layer, photo capture, movie recording, or real time frame processing.

Core Bluetooth: The Central vs. Peripheral Model
Core Bluetooth lets your app talk to BLE devices by acting as a "Central" (scanner) or "Peripheral" (advertiser). Use it to read from sensors or make your app discoverable.

ARKit: Building Augmented Reality on Apple Devices
ARKit is Apple's framework for blending digital objects with the real world using a device's camera. Use it for games, virtual furniture previews, or measurement tools.

iOS Geofencing: Your App's Virtual Fence
Geofencing sets a virtual perimeter and lets iOS wake your app when a user enters or exits, without constant tracking. Use it for location-based reminders or context-aware features.

HealthKit: The Secure Vault for User Health Data
HealthKit is a secure, centralized database for user health data, not a sensor. Your app requests permission to read or write data like steps or workouts, which the OS manages. The footgun is assuming access; users grant permissions per data type.

StoreKit
StoreKit is Apple's framework for in-app purchases and subscriptions. It manages product lookup, presenting the payment sheet, processing transactions, and restoring purchases, so apps never touch raw payment data directly.

Vision Framework: Computer Vision on Apple Devices
The Vision framework is your on-device toolkit for understanding images and video. Use it for face detection, text recognition, or barcode scanning without needing ML expertise. Footgun: don't run requests on every frame; it drains the battery.

Core ML: On-Device Machine Learning for Apple Apps
Core ML runs pre-trained machine learning models directly on Apple devices, enabling fast, private, and offline AI. It's used for features like real-time image recognition or text analysis. The footgun: Core ML only runs models; it doesn't train them.

AVFoundation: Apple's Toolkit for Audio and Video
AVFoundation is Apple's low-level toolbox for audio and video. Use it for custom camera UIs, video editing, or complex audio playback. The main footgun is its complexity; managing sessions, inputs, and outputs on the correct threads is notoriously difficult.

MapKit: Putting Apple Maps in Your iOS App
MapKit is the toolkit for embedding Apple's interactive maps directly into your app. Use it to show user location, display points of interest, or provide directions. The footgun is rendering too many pins at once; use clustering to keep the UI responsive.

Core Location: Your App's Sense of Place
Core Location gives your app its sense of place, from a precise coordinate to a general region. It powers maps, ride-sharing, and location-based reminders. Use it for one-time fixes, continuous tracking, or geofencing.

CAReplicatorLayer: A 'For Loop' for Layers
CAReplicatorLayer is a 'for loop' for layers, creating complex patterns from a single source layer. Use it for loading spinners or radial bursts. The footgun: transformations are cumulative, so each copy is transformed relative to the previous one, not the…

GeometryEffect
GeometryEffect is a SwiftUI protocol for building custom animatable 2D transforms beyond the built-in offset, scaleEffect, and rotationEffect modifiers, by returning a ProjectionTransform that SwiftUI recomputes and animates on every frame.

The Animatable Protocol
The Animatable protocol lets a custom SwiftUI view or Shape expose its state as interpolatable data, so SwiftUI can smoothly tween between values across frames instead of snapping, which is how custom shapes and progress indicators get real animation.

CATransaction: Grouping Core Animation Changes
Think of CATransaction as an atomic 'commit' for UI animations, grouping layer property changes to appear at once. Use it to synchronize animations or set a custom duration for a batch of changes.

CAKeyframeAnimation: Animating Through Key States
CAKeyframeAnimation defines animations with waypoints, not just a start and end. Think of it as a flipbook where you set key frames and the system interpolates. Use it for complex paths, like shaking an icon. Footgun: setting both `path` and `values`.

Canvas in SwiftUI
Canvas is SwiftUI's view for fast, immediate mode drawing. Instead of composing many shape views, you draw paths, text, and images directly into a GraphicsContext, which is far cheaper for complex or animated graphics.

Creating Custom Gestures by Subclassing UIGestureRecognizer
Subclassing UIGestureRecognizer lets you build a custom state machine for touch events. Use it for unique interactions like a rotary dial. The footgun is state management: you must explicitly update the gesture's state or it will never be recognized.

CAShapeLayer: Hardware-Accelerated Vector Drawing
A CAShapeLayer is a GPU-powered stencil for drawing vector shapes. It renders paths like lines and curves far more efficiently than drawing in `draw(_:)`. Use it for custom UI like progress rings.