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.

4330 bites

Page 138

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

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

Display thousands of map annotations efficiently

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

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

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 & 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 & 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 & 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 & 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

Locating XCUITest elements without accessibility identifiers

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

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

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

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

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

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

Modularizing a monolithic iOS app

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

iOS & Swift1 min read

Static library versus dynamic framework linking

Static code is copied into the executable at build time; dynamic is loaded at launch by dyld. Trade-off: static bloats the binary but avoids load cost; many dynamic frameworks slow launch.

iOS & Swift2 min read

Developing a local Swift Package alongside an app

Add the package as a local dependency by dragging its folder into the project or workspace, so Xcode references the source on disk and rebuilds edits immediately.

iOS & Swift2 min read

App ID, provisioning profile, and signing certificate

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.

iOS & Swift1 min read

Archiving and uploading a build to TestFlight

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.