Work with motion, location, and environmental measurements as fallible streams of data. The series covers permissions, coordinate systems, signal quality, and lifecycle cleanup, and each article ends with an exercise.
Every claim is measured. The examples use Swift 6 language mode and were compiled and run with the Swift 6.4 toolchain from Xcode 27.1. Core Location and Core Motion code ran in an app-hosted test bundle on an iPhone 17 simulator running iOS 27.0, with routes scripted by simctl and the real permission alerts and Settings switches tapped by a UI test. The simulator has no motion sensors, so the motion articles pair Apple’s documented behavior with simulations from stated sensor models, each checked against the formula it should reproduce, and the simulator article lists what still needs a device. The testing articles are Swift packages run with swift test.
Article available Coming soon
1. Availability and Permissions
Checking Sensor Availability Before Starting Work
A feature built on a sensor makes a promise the hardware may not be able to keep. A floor counter needs a...
Requesting Motion and Location Permissions in Context
A permission alert is a question an app gets to ask once. If the user taps Don’t Allow, later requests show nothing...
Handling Permission Changes and Reduced Accuracy
The permission an app gets at the alert isn’t the permission it keeps. Users change their minds in Settings, Allow Once expires,...
Device Testing vs. Simulator Capabilities
The iOS simulator is the fastest place to run sensor code and the least faithful one. It has no accelerometer, no gyroscope,...
2. Motion and Orientation
Accelerometer and Gyroscope Measurements
Every iPhone carries a three-axis accelerometer and a three-axis gyroscope, and Core Motion will deliver their raw readings a hundred times a...
Device Motion, Gravity, and User Acceleration
An accelerometer can’t tell gravity from motion. A phone tilted 17 degrees and a phone braking at 0.3 g in a car...
Attitude, Reference Frames, and Coordinate Conversion
An attitude is a rotation, and a rotation is only meaningful once two things are pinned down: which frame it’s measured from,...
Pedometer Data and Activity Recognition
The step count on an iPhone’s lock screen widget never stopped. The motion coprocessor counts steps all day, whether or not any...
Altitude, Pressure, and Relative Measurements
A barometer is a remarkable altimeter over a minute and a poor one over an afternoon. Air pressure falls by about one...
Sampling Rates, Noise, Filtering, and Drift
Every sensor feature is a small signal-processing pipeline, whether or not its author thinks of it that way. A rate is chosen,...
3. Location and Heading
Location Updates and Accuracy Requirements
A CLLocation looks like an answer and is really a claim: “the device is probably within this many meters of this point,...
Distance Filters and Energy-Aware Tracking
Tracking a route costs energy in two places. The radios and the location processors do the measuring, and Core Location decides how...
Heading, Compass Calibration, and Magnetic Interference
A phone’s compass measures the Earth’s magnetic field, a few tens of microtesla, from inside a case full of steel screws, speaker...
Region Monitoring and Geofencing
A geofence asks a yes-or-no question, “is the user inside this circle?”, of data that only ever answers “probably”. Near the edge,...
Visits and Significant Location Changes
Most apps that care where their users go don’t need to know where they are every second. A journal wants the places...
Geocoding, Reverse Geocoding, and Request Limits
Turning coordinates into “Elizabeth Tower, London” and an address into coordinates is a network request to Apple’s servers, and it’s rationed. iOS...
Background Location and App Lifecycle Boundaries
A location feature crosses the app’s lifecycle boundaries constantly. The user starts a run and locks the phone. A geofence fires while...
4. Interpreting Sensor Streams
Timestamps, Stale Samples, and Out-of-Order Events
A sensor sample has two times: when it happened and when the app heard about it. Most bugs in sensor code come...
Combining Motion and Location Without Shared-State Races
Motion and location complement each other almost perfectly. GPS knows where the device is to within meters, but only once a second,...
Distinguishing Missing Data from a Valid Zero Reading
Zero is a measurement. A speed of 0 means standing still, zero floors means a flat day, and a heading of 0...
Designing Features Around Uncertainty and Accuracy
Every number a sensor produces comes with an error, and most features throw the error away at the first opportunity. A distance...
5. Testing and Resource Use
Injecting Recorded Sensor Data for Deterministic Tests
Sensor code is hard to test for two reasons that look unrelated. Its input comes from hardware: a test can’t walk around...
Testing Unavailable Hardware and Denied Permissions
The paths that matter most in a sensor app are the ones developers see least. A developer’s phone has every sensor, and...
Stopping Updates When a Feature Ends
Starting a sensor is one line of code, and the bug is in the line that’s missing. A screen starts location updates...
Profiling Sensor Work and Battery Usage
When a sensor app drains batteries, the instinct is to optimize the math: a faster filter, a leaner Kalman update. The measurements...
Up next
Accessibility