With Xcode 27’s iOS 27 Simulator, CLLocationManager.startMonitoring(for:) may fail with Error Domain=kCLErrorDomain Code=5 "(null)" even though the same code works on a physical device and an iOS 26 Simulator. This article explains how to distinguish the reported Simulator behavior from ordinary region configuration errors, the affected conditions, safe workarounds, and verification steps.
Representative error
locationManager(_:monitoringDidFailFor:withError:)
Error Domain=kCLErrorDomain Code=5 "(null)"
The same reported setup also returns:
CLLocationManager.isMonitoringAvailable(
for: CLCircularRegion.self
)
// false
What Code 5 means
kCLErrorDomain Code=5 maps to kCLErrorRegionMonitoringFailure. Apple defines it as a failure to monitor a registered region. Ordinary causes include exceeding the maximum number of monitored regions or requesting a region radius that is too large.
The behavior reported with Xcode 27
An Apple Developer Forums report describes isMonitoringAvailable(for: CLCircularRegion.self) always returning false in an iOS 27 Simulator under Xcode 27. Calling startMonitoring then reports Code 5. The same app reportedly works on physical hardware and in an iOS 26 Simulator.
Important: Apple has not confirmed whether this is intentional Simulator behavior or an Xcode 27/iOS 27 Simulator defect. No root cause or fixed version was confirmed as of September 28, 2026.
Affected conditions and versions
- Xcode 27
- An iOS 27 Simulator
- Registering a
CLCircularRegionwithCLLocationManager.startMonitoring(for:) - Code 5 delivered to
locationManager(_:monitoringDidFailFor:withError:) isMonitoringAvailable(for:)returnsfalse- Reported not to reproduce on a physical device or an iOS 26 Simulator
Rule out normal configuration failures first
- Confirm that Location Services are enabled.
- Confirm that the app has the required authorization.
- Make sure
monitoredRegionshas not reached the 20-region limit. - Keep the requested radius within
maximumRegionMonitoringDistance. - Validate the center coordinate and region identifier.
let available = CLLocationManager.isMonitoringAvailable(
for: CLCircularRegion.self
)
print("Region monitoring available:", available)
print("Monitored count:", manager.monitoredRegions.count)
print("Maximum radius:", manager.maximumRegionMonitoringDistance)
Recommended steps
1. Check availability before registration
guard CLLocationManager.isMonitoringAvailable(
for: CLCircularRegion.self
) else {
print("Region monitoring is unavailable on this runtime")
return
}
manager.startMonitoring(for: region)
This prevents an unsupported runtime from continuing into registration and gives CI logs a clear failure reason.
2. Verify the feature on physical hardware
Region monitoring depends on system location services and device capabilities. Because the report states that the physical device works, run functional geofence tests on an iPhone or iPad as well.
3. Temporarily keep automation on an iOS 26 Simulator
If an existing system test fails only on the iOS 27 Simulator, isolate the region-monitoring test on an iOS 26 Simulator or a physical-device job until Apple clarifies the behavior. This is a workaround, not evidence that Xcode 27 has been fixed.
4. Implement the failure callback
func locationManager(
_ manager: CLLocationManager,
monitoringDidFailFor region: CLRegion?,
withError error: Error
) {
let nsError = error as NSError
print("Region:", region?.identifier ?? "nil")
print("Domain:", nsError.domain)
print("Code:", nsError.code)
print("Details:", nsError.userInfo)
}
Apple recommends implementing this delegate callback whenever an app uses region monitoring.
Alternatives
- Separate iOS 27 UI tests from physical-device region-monitoring tests.
- Abstract region registration and use a mock to test application state transitions in Simulator-only jobs.
- Evaluate migration from deprecated
CLCircularRegionAPIs to the newer condition-monitoring APIs.
Apple has not stated that moving to the newer API fixes this reported Simulator behavior, so do not present migration as a confirmed remedy.
How to verify
- Run the same build on an iOS 27 Simulator, an iOS 26 Simulator, and a physical device.
- Record the result of
isMonitoringAvailable(for:). - Check whether
didStartMonitoringForormonitoringDidFailForis called. - On hardware, cross the boundary and verify entry and exit delivery.
Cautions
- Code 5 alone does not prove an Xcode 27 Simulator issue.
- Simulated location changes do not fully reproduce hardware background behavior or geofence delivery.
CLCircularRegionandstartMonitoring(for:)may be marked deprecated in current SDKs.- Apple has not published a confirmed fixed version.
Summary
If the iOS 27 Simulator reports Error Domain=kCLErrorDomain Code=5 and isMonitoringAvailable is also false, first rule out authorization, radius, and region-count problems. If the failure remains isolated to the iOS 27 Simulator, move the affected test to physical hardware or an iOS 26 Simulator and keep the root cause qualified until Apple publishes more information.
