Skip to content
tezvyn:

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

iOS & Swift1 min read

Modularizing a monolithic iOS app

Extract low-dependency, high-reuse leaf code first behind clear interfaces, enforce boundaries, iterate inward.

iOS & Swift1 min read

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.

iOS & Swift1 min read

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.

iOS & Swift1 min read

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.

iOS & Swift1 min read

Diagnosing and stabilizing flaky XCUITests

Identify timing races, animations, network variance, and shared state; fix with expectations, controlled launch state, and isolation.

iOS & Swift1 min read

Code coverage and its pitfalls

It measures executed lines, surfaces untested paths, and guides where to add tests.

iOS & Swift1 min read

Locating XCUITest elements without accessibility identifiers

Query by type, label, predicate, or index; chain queries to narrow scope.

iOS & Swift1 min read

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.

iOS & Swift1 min read

Unit test a ViewModel with a mocked NetworkService

Inject the protocol, supply a mock returning canned data, assert published state transitions.

iOS & Swift2 min read

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.

iOS & Swift2 min read

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.

iOS & Swift1 min read

React to location authorization changed in Settings

Implement locationManagerDidChangeAuthorization, which fires on launch and whenever status changes, read authorizationStatus, and start updates when authorized.

iOS & Swift1 min read

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.

iOS & Swift1 min read

Display thousands of map annotations efficiently

Enable clustering via clusteringIdentifier, reuse views with dequeueReusableAnnotationView, render clusters with MKClusterAnnotation in viewFor.

iOS & Swift1 min read

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.

iOS & Swift1 min read

Track location continuously in the background

Set desiredAccuracy, distanceFilter, activityType; enable the Location background mode and allowsBackgroundLocationUpdates; request Always authorization.

iOS & Swift1 min read

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).

iOS & Swift1 min read

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.

iOS & Swift1 min read

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.

iOS & Swift1 min read

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…