All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
8668 bites
Page 74
Modularizing a monolithic iOS app
Extract low-dependency, high-reuse leaf code first behind clear interfaces, enforce boundaries, iterate inward.
Package.swift manifest: library vs executable products
The manifest declares name, targets, dependencies, and products; a library is consumed by other code while an executable produces a runnable binary with an entry point.
Adding a Swift Package dependency in Xcode
Add via File menu, paste the repo URL, choose a version rule like up-to-next-major, link the product to your target.
Driving app state via launch arguments in XCUITest
Pass launchArguments and launchEnvironment, read them at startup to seed auth and flags, bypassing slow UI steps.
Diagnosing and stabilizing flaky XCUITests
Identify timing races, animations, network variance, and shared state; fix with expectations, controlled launch state, and isolation.
Code coverage and its pitfalls
It measures executed lines, surfaces untested paths, and guides where to add tests.
Locating XCUITest elements without accessibility identifiers
Query by type, label, predicate, or index; chain queries to narrow scope.
Testing async code and completion handlers in XCTest
Create an expectation, fulfill it inside the completion handler, call wait with a timeout, or use async test methods.
Unit test a ViewModel with a mocked NetworkService
Inject the protocol, supply a mock returning canned data, assert published state transitions.
Unit test versus UI test in Xcode
Unit tests (XCTest) exercise code logic in-process and fast; UI tests (XCUITest) drive the app through the accessibility layer, slower and end-to-end.
Recognize objects in ARKit with a Core ML model
Pull the frame's capturedImage, run Vision/Core ML off the main thread, raycast the 2D detection point into the scene, add an ARAnchor.
React to location authorization changed in Settings
Implement locationManagerDidChangeAuthorization, which fires on launch and whenever status changes, read authorizationStatus, and start updates when authorized.
Apply a CIFilter to a live camera feed
Use AVCaptureSession with AVCaptureVideoDataOutput, receive CMSampleBuffers in captureOutput via the sample buffer delegate on a serial queue, filter with CIImage, drop late frames.
Display thousands of map annotations efficiently
Enable clustering via clusteringIdentifier, reuse views with dequeueReusableAnnotationView, render clusters with MKClusterAnnotation in viewFor.
Run a Core ML image model with Vision
Add the .mlmodel so Xcode generates a class, wrap it in a VNCoreMLModel, run a VNCoreMLRequest via a VNImageRequestHandler, read results off the main queue.
Track location continuously in the background
Set desiredAccuracy, distanceFilter, activityType; enable the Location background mode and allowsBackgroundLocationUpdates; request Always authorization.
Play a remote video with AVFoundation
Wrap the URL in AVPlayerItem, feed it to AVPlayer, render with AVPlayerLayer added to the view's layer (or AVPlayerViewController for controls).
Request the user's location one time
Add a usage description to Info.plist, set a CLLocationManager delegate, request when-in-use authorization, call requestLocation, handle didUpdateLocations and didFailWithError.
Animate a SwiftUI Shape morphing point count
Expose a continuous sides value as animatableData so SwiftUI interpolates it, then compute the path from that fractional value each frame.
Build an interruptible custom VC transition
A delegate vends an animator (UIViewControllerAnimatedTransitioning) for the visuals and an interactive controller (UIViewControllerInteractiveTransitioning) driven by a pan to scrub progress and…