Maps & Location

RSS for tag

Learn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.

Maps & Location Documentation

Posts under Maps & Location subtopic

Post

Replies

Boosts

Views

Activity

Inquiry About Background Permission Issue in My App
I am writing to address a concern regarding the background permission functionality in my app, which is critical for ensuring user safety as they navigate various terrains. This feature also enables users to smoothly record their navigation tracks for review after their activities. Recently, I've noticed that this functionality is not working as seamlessly as before. Additionally, I observed that the app is not categorized under 'health and fitness'—could reclassifying it improve background activity? Before I delve into a detailed code review, I wanted to check if this issue might be related to sync or settings on the App Store side, such as permission configurations, app updates, or other related factors. Or, is it more likely an issue stemming from the app’s codebase?
1
0
443
Jan ’25
[Regression] Core Location underground positioning inaccurate on iOS 26.1 beta (23B5044i)
Summary While parallel testing Core Location on the new iOS 26.1 beta (23B5044i), I observed what I believe to be a regression of the issue described here: https://developer.apple.com/forums/thread/779192 Specifically, user positioning underground subway stations is noticeably inaccurate on the beta, whereas the same scenarios remain accurate on the unupgraded device below. I work with the MTA (New York City) and work with the OP of that thread. Happy to provide additional testing or details if helpful. Please let me know what else you need. Test Info Riding NYCT from Wall St to 34th St Penn Station on the 2 train carrying two iphones Recording: https://limewire.com/d/dpTWi#pDC3GRYIdE Expected: Consistent underground positioning comparable to prior releases. Actual: Degraded/inaccurate underground positioning on iOS 26.1 beta. Test Devices Left Screen: iPhone 15 Pro Max - iOS 26.1 beta (23B5044i) Right Screen: iPhone 11 - iOS 18.6.2 (22G100) Blue dots show location set by CoreLocation. Red dot on iphone 11 shows the actual location of both devices as I was able to manually place while travelling through a station. Placement through tunnels is not easy to verify and not usually indicated. Timestamps Comparison of when train was actually observed in a station vs when 26.1 and 18.6.2 CoreLocation updated to the station Fulton St 1:48 iOS 26.1 correctly updates (correctly) 2:16 iOS 18.6.2 updates (28sec late) Park Place 4:12 train arrives 4:15 iOS 18.6.2 updates to ~near Park Place 5:04 iOS 18.6.2 updates to Park Place (correctly) 6:07 iOS 26.1 update to ~near Park Place (over 2 mins late) Chambers St 6:02 train arrives / iOS 18.6.2 updates (correctly) 6:14 iOS 26.1 updates to ~near Chambers 6:18 iOS 26.1 update to Chambers (correctly) Franklin St 6:52 train arrives 6:55 iOS 18.6.2 updates (correctly) x:xx iOS 26.1 does not update Canal St: 7:16 train arrives 7:18 iOS 18.6.2 updates (correctly) x:xx iOS 26.1 does not update Houston St 7:54 train arrives 8:00 iOS 18.6.2 updates (correctly) x:xx iOS 26.1 does not update Christopher St 8:37 iOS 26.1 presumably between Houston St and Christopher St 8:40 train arrives / iOS 18.6.2 updates (correctly) x:xx iOS 26.1 does not update 14 St 9:22 train arrives 9:28 iOS 18.6.2 updates (correctly) 11:01 as train departs station iOS 26.1 updates (1.5 mins late)
1
0
69
2d
CLMonitor init function causes app crash
I'm experiencing app crashes when calling the CLMonitor initialization function: let monitor = await CLMonitor("my_monitor") According to WWDC 2023: Meet Core Location Monitor, when creating a CLMonitor object with the same identifier, it should access the existing monitor without any mention of app crashes or buggy behavior. However, in my actual testing, attempting to create a CLMonitor object with the same identifier immediately causes an app crash. Here's part of the crash log: Last Exception Backtrace: 0 CoreFoundation 0x19c4ab21c __exceptionPreprocess + 164 (NSException.m:249) 1 libobjc.A.dylib 0x199945abc objc_exception_throw + 88 (objc-exception.mm:356) 2 Foundation 0x19b7a9670 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 288 (NSException.m:252) 3 CoreLocation 0x1aa25cbb4 +[CLMonitor _requestMonitorWithConfiguration:locationManager:completion:] + 516 (CLMonitor.mm:516) 4 libswiftCoreLocation.dylib 0x22bf6085c CLMonitor.init(_:) + 488 (CLMonitor.swift:280) 5 libswiftCoreLocation.dylib 0x22bf604b9 <deduplicated_symbol> + 1 6 MiniPlengi 0x106372ec9 closure #1 in static CLMonitor.loplatMonitor.getter + 1 (CLMonitor+Extensions.swift:31) 7 MiniPlengi 0x1062ce325 0x106290000 + 254757 8 MiniPlengi 0x1062f6a29 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1 (/<compiler-generated>:0) 9 MiniPlengi 0x1062ce325 0x106290000 + 254757 10 libswift_Concurrency.dylib 0x1a7f75241 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:537) Furthermore, even though I've written code to create CLMonitor objects based on a singleton structure to handle these crash cases, the app still crashes: extension CLMonitor { static var loplatMonitor: CLMonitor { get async { struct Static { static var monitor: CLMonitor? static var initializationTask: Task<CLMonitor, Never>? } // If already initialized if let monitor = Static.monitor { return monitor } // If there's an initialization task in progress, wait for its result if let task = Static.initializationTask { return await task.value } // Create new initialization task let task = Task { let monitor = await CLMonitor("my_monitor") Static.monitor = monitor Static.initializationTask = nil // Clean up task after completion return monitor } Static.initializationTask = task return await task.value } } } Is the CLMonitor API still in a stabilization phase and not recommended for production release? I would appreciate guidance on the correct usage. If these issues are expected to persist, I'm wondering if I should continue using the existing CLCircularRegion API instead. Any insights or recommendations would be greatly appreciated.
1
0
39
6d
Maps Web Snapshots: 500 Internal Server Error
Currently (at least for a few days, maybe longer), when trying to create an Apple Maps Web Snapshot according to https://developer.apple.com/documentation/snapshots/generating_a_url_and_signature_to_create_a_maps_web_snapshot with a custom image marker (passed as Base64 PNG), the Apple server responds with a 500 Internal Server Error. Using the default balloon marker works, but a custom Base64 image marker used to work in the past (and still should according to the documentation).
1
1
192
Mar ’25
Apple maps trail / local path only becomes visible on very close zoom
I'm using apple maps to build a feature so users can create and save running/cycling/hiking routes. Currently the map only shows trails and similar local paths after zooming in to what is basically an extreme level. I want the trails and local paths to be more visible on a further, broader level of zoom. APPLE MAPS JS EX: https://trkbucket.s3.amazonaws.com/media/shoe_images/Screenshot_2024-10-23_at_10.52.17AM.png https://trkbucket.s3.amazonaws.com/media/shoe_images/Screenshot_2024-10-23_at_10.52.04AM.png APPLE MAPS iOS EX: https://trkbucket.s3.amazonaws.com/media/shoe_images/IMG_9DDF5C9A320D-1.jpeg Also strange that on iOS the path is visible while more zoomed out whereas JS does not. Please advise how to show these map items at a broader zoom.
1
0
581
Oct ’24
Sync Conflict Between Contacts & Maps, Possible Cross-App Link with Home App Issue
Pinned 2 homes address for the same contact Steps Initial check in Apple Maps No saved places or pinned addresses appear. Open Personal Contacts You have two addresses stored in your contact card: Main and Home. Pin & Edit “Main” You pinned the Main address in Maps. Refined the location on the map. Renamed it (but still saved under the type “My Home”). Open “Home” Address in Contacts Refined the location again. Changed the type to “My Home.” Attempted to rename, but no option to change the label. Final Saved Places View Shows two entries both called “Main.” Opening either of them displays the same details for the Home address. Saved Places list only shows the full address text, without the ability to rename them inside Maps. Results Both addresses appear duplicated with the same name (“Main”), even though they point to different underlying addresses. When selecting either entry, Apple Maps incorrectly shows the same Home address details. The Saved Places section does not allow renaming; it defaults to showing the full address string. Issues Identified Sync Conflict Between Contacts & Maps Apple Maps pulls labels/types from Contacts, but the edits don’t update consistently across apps. Duplicate Naming Bug Both “Main” and “Home” collapse into “Main” in Saved Places, making them indistinguishable. One-to-One Mapping Failure Regardless of which saved place you open, Maps shows the same Home entry, meaning the system isn’t correctly binding each saved place to its respective contact address. Renaming Limitation Apple Maps doesn’t allow renaming saved addresses directly — it relies on Contacts. Since Contacts only supports preset labels (Home, Work, School, etc.), custom naming is blocked.
1
0
72
2w
Apple Maps really sluggish
After upgrading to iOS 18.1, apple maps is really slow. I thought it was the app so I switched to google maps and same issue. I have tried all (including reseting the iPhone) but it did not fix it. I had iPhone 15 proMax, but since nothing worked, I upgraded to i16 but .... nothing. Any idea on how to get it fixed?
1
0
521
Nov ’24
Beacon Exits region and is unavailable for extended periods
Hi, We are using beacon ranging methods to detect beacon in foreground and background in our app. We are using beacon's UUID, major and minor values to create a beacon region and then calling locationManager.startRangingBeacons to range beacons. We listen for beacon updates via the didRangeBeacons delegate method to get beacon data emitted. However, we've observed some inconsistent behavior: The beacon region frequently reports exit events even when the device is within close proximity (approximately 1.5 to 2 meters). There are instances where no beacon updates are received for extended periods (up to 15–20 minutes), despite the beacon being nearby. Generally, The distance between the device and the beacon is approximately 1.5 - 2 meters. What could be the reason for this behaviour and how can we avoid it and continuously receive beacon updates when the beacon is near without any delay? Thanks
1
0
13
1d
SwiftUI issue with onTap using Map using IOS 26
I have a sample that stop working on IOS 26, using the latest XCode and IOS sdk, the onTapGesture event is no longer happening. Maybe this is no longer the way to drop pins on the map. Also not working on the iPhone 17 sim or iPhone 16 max pro device upgrading to IOS 26 Thanks, any help Sample: import SwiftUI import MapKit import CoreLocation import Foundation struct Pin: Identifiable { let id = UUID() let coordinate: CLLocationCoordinate2D } struct ContentTestPinDropView: View { @State private var pins: [Pin] = [] var body: some View { MapReader { reader in Map(selection: .constant(nil)) { ForEach(pins) { pin in Marker("Pin", coordinate: pin.coordinate) } } .onTapGesture { screenPoint in if let coordinate = reader.convert(screenPoint, from: .local) { pins.append(Pin(coordinate: coordinate)) } } } } }
1
0
66
1w
Iphone is deleting my messages automatically
I have checked the setting and it is and has always been set to forever when it comes to settings-messages-message history. Yet since I upgraded to ios 18.1, my messages have started to delete by themselves every other day or so. In the last week, I have had to go into the recently deleted and recovered the messages at least 3-4 times. It does not delete all my messages just random messages from whom I have messaged recently. I have message that have been there for at least 6 years and those are not deleting. Please help before I lose some valuable messages.
1
0
725
Oct ’24
CarPlay map view stops updating when iPhone screen turns off
Hello all, I have a food delivery app that I am beginning to implement CarPlay support in. Route picking, navigation, turn-by-turn guidance features all work perfectly on iPhone, and on CarPlay while the iPhone is unlocked, or locked but screen on. However, when the iPhone is locked and the screen is off, the CarPlay map view stops following the user's location and appears to be frozen. When this happens, the other "map buttons" that are part of the CPMapTemplate continue to accept user input (I can enter and exit the map panning mode for example), the user's location continues to update, and the turn-by-turn guidance continues as normal. It appears to be just the map view (which is drawn on the window and is not part of the CPMapTemplate) that stops updating in this state. I've been through every page of Apple documentation on CarPlay but nothing references or addresses how to keep the CarPlay session active while the iPhone is locked. I'm not sure where else to look for answers and I'm out of theories as to why this might happen. Any guidance around this would be greatly appreciated.
1
0
86
Mar ’25
didEnterRegion and didExitRegion delegate methods are called twice
When I set the values of notifyOnExit and notifyOnEnter to true when registering CLCircularRegion, I checked that the didExitRegion and didEnterRegion functions are called well. However, there is a problem that they are called twice in a row every time they are called. I was wondering if this is an internal bug in the API. There is also a stackoverflow report related to the above issue. I would appreciate your confirmation. stackoverflow - why the didEnterRegion called twice? Thank you.
1
0
509
Dec ’24
Guidance on Continuous Location & Direction Updates to watchOS App Without Screen Dimming
Dear Apple Developer Support, I am reaching out for guidance on implementing continuous directional and location updates in a watchOS app designed as part of a mapping/navigation solution. Current Scenario: We send continuous location and direction updates from our iOS app to the watchOS companion app. When viewing directions on the Apple Watch, the screen dims after a short period, and the live data stops updating consistently, even though the user is actively looking at the screen. This negatively impacts the usability of real-time navigation on watchOS. Our Objective: Prevent screen dimming (or extend screen-on time) while the user is viewing navigation directions. Ensure reliable, continuous data updates on the watch screen during active navigation sessions. Request: We would appreciate your guidance on: The recommended method to keep the watchOS screen active while displaying real-time navigation data. Proper use of APIs such as WKExtendedRuntimeSession, WorkoutSession, or any other mechanism suitable for this use case. Any best practices or App Store review considerations for apps that require extended screen time and continuous updates. How such use cases were traditionally handled on watchOS and what has or hasn’t worked. We want to ensure we're implementing this in a battery-efficient, user-respectful, and Apple-compliant manner. Thank you for your assistance and guidance.
1
0
63
Apr ’25
Core Location always failing (kCLErrorLocationUnknown)
Hello. I’m trying to use Core Location Service on any application in Mac (Safari, Maps, Weather, Chrome with Core Location configuration, or just trigger the API with a standalone app) and it seems that all of them constantly fail to provide the geolocation of my device because of the same error (kCLErrorLocationUnknown). I'm using MacBook Pro (M3 Max) with Sonoma 14.7. I’m sure the apps have access in the settings and everything is in order except the Core Location response. I’ve tested the issue on multiple MacBooks and it reproduced 100% of the times on all of them. Did anyone encounter a similar issue?
1
4
2.1k
Oct ’24
GPS Icon Appears on App Launch Despite No CLLocationManager Usage – Need Help Tracing Cause
Hello everyone, I’m facing an issue with my iOS app where the GPS/location services icon appears in the status bar immediately when the app is launched, even though I’m not intentionally accessing location services at that point. Issue Summary: • GPS Icon Activation: When I launch my app, the GPS icon turns on. It turns off when the app is minimized or closed. • No Intentional Location Usage at Launch: I have ensured that no instances of CLLocationManager are created when the app is launched. What I’ve Tried So Far: 1. Checked Controllers and Related Classes: • Reviewed all the code for the controllers that are active at launch. • Verified that none of these controllers create instances of CLLocationManager or call location-related methods. 2. Commented Out startUpdatingLocation: • Commented out all calls to startUpdatingLocation throughout the entire project. 3. Ensured No CLLocationManager Instances at Launch: • Searched for any code that might instantiate CLLocationManager during app launch. • Confirmed that no such instances are being created. 4. Commented Out Google Maps SDK Configuration: • In AppDelegate, commented out the Google Maps SDK configuration, so it’s not initialized with the API key. • No map views (GMSMapView, MKMapView) are initialized or used when the app is launched. 5. Tested Location Permissions: • When I change the location permission for the app to “Never” in the Settings app, the GPS icon does not appear upon app launch. • This suggests that the app is accessing location services when it has permission, even though I haven’t explicitly requested it at launch. Objective: • Control GPS Activation: I want to ensure that the GPS does not turn on when the app is launched. I intend to activate location services only when needed later in the app. Request for Assistance: I’m seeking guidance on the following: 1. Debugging Techniques: • How can I trace the code that’s causing the GPS to turn on at app launch? • Are there tools or methods to identify hidden or indirect calls to location services? 2. Forcing Location Services Off at Launch: • Is there a way to programmatically prevent location services from activating during app launch? • Can I defer any implicit location service initialization until I explicitly enable it? 3. Potential Hidden Triggers: • Are there known scenarios where location services could be activated without direct use of CLLocationManager? • Could frameworks like Google Maps SDK trigger location services even if not fully initialized? 4. Additional Suggestions: • Any other insights or suggestions to prevent the GPS icon from appearing on app launch. Additional Information: • Third-Party Frameworks: • I have not removed third-party frameworks yet, as I wanted to check other possibilities first. • Open to the idea that a third-party framework might be causing this, but need guidance on how to confirm. • Code Availability: • I’m happy to provide specific code snippets if that would help diagnose the issue. Environment: • Xcode Version: Xcode 15.4, Xcode 16.0 • iOS Deployment Target: iOS 15.0 • Devices Tested: iPhone SE 2nd and 3rd gen, iPhone 15, iPhone 15 pro, iPhone 11 • Programming Language: Swift What I’m Looking For: • Assistance in tracing the cause of the GPS activation on app launch. • Suggestions on how to prevent location services from starting until explicitly needed. • Insights into any hidden triggers or indirect usages that might cause this behavior. Thank you for your time and assistance. Any help to resolve this issue would be greatly appreciated.
1
1
413
Oct ’24
Issue with calculating the distance between two points on a map
I have an error issue that I haven’t been able to solve despite doing extensive research. In fact the similar examples I have found so far have been educational but I have not been able to make work. The example below I am hoping will be easy to fix as it is only producing errors with one line of code… import SwiftUI import CoreLocation var currentLon = Double() var currentLat = Double() extension CLLocation { class func distance(from: CLLocationCoordinate2D, to: CLLocationCoordinate2D) -> CLLocationDistance { let from = CLLocation(latitude: from.latitude, longitude: from.longitude) let to = CLLocation(latitude: to.latitude, longitude: to.longitude) return from.distance(from: to) } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { currentLon = (locations.last?.coordinate.longitude)! currentLat = (locations.last?.coordinate.latitude)! }/*⚠️ Not sure if this function will work? (Update User Location coordinates on the move?)*/ } struct Positions: Identifiable { let id = UUID() let name: String let latitude: Double let longitude: Double var coordinate: CLLocationCoordinate2D { CLLocationCoordinate2D(latitude: latitude, longitude: longitude) } } struct GameMapView: View { let from = CLLocationCoordinate2D(latitude: currentLon, longitude: currentLat) let to = CLLocationCoordinate2D(latitude: thisCardPositionLongitude, longitude: thisCardPositionLongitude) let distanceFrom = from.distance(from: to) /*⚠️ ERRORS: 1. Cannot use instance member 'from' within property initializer; property initializers run before 'self' is available. 2. Cannot use instance member 'to' within property initializer; property initializers run before 'self' is available. 3. Value of type 'CLLocationCoordinate2D' has no member 'distance'. */ @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D( latitude: thisCardPositionLatitude, longitude: thisCardPositionLongitude), span: MKCoordinateSpan( latitudeDelta: 0.0001, longitudeDelta: 0.0001) ) var body: some View { Map(coordinateRegion: $region, showsUserLocation: true, annotationItems: locations){ place in MapMarker(coordinate: place.coordinate,tint: Color.accentColor) } .edgesIgnoringSafeArea(.all) VStack { Print("Distance from Location: \(distanceFrom)") font(.largeTitle) padding() }
1
0
100
Apr ’25
Specify location for SwiftUI Previews
I'm working on an app that uses MapKit and CoreLocation. Is there a way to specify what location is simulated for a Preview, or create a preview that behaves as if the user denied location permissions, so that I can easily test my app's behavior in different scenarios? I know that you can simulate different locations in the Simulator, but haven't been able to get the previews within Xcode to have a location other than the center of Apple Park.
0
0
69
Apr ’25
The UWB performance of iOS18 is different from that of iOS17
Hello, dear engineer: The UWB Accessory used by my APP has inconsistent code callbacks on iOS17 and iOS18. I have connected multiple UWB Accessory by Accessory Single Configuration Data (UUID: 95e8d9d5-d8ef-4721-9a4e-807375f53328) in the APP. In iOS17.5.1, the unconnected Accessory calls the func session in the NiSessionDelegate (_ session: NISession, didRemove nearbyObjects: [NINearbyObject], "reason: NINearbyObject RemovalReason)," reason is the timeout. iOS18.0.1 does not call didRemove and fails to connect automatically after 10 minutes on the disconnected Accessory. iOS18.2 does not call didRemove. After 10 minutes, when the Accessory is not connected, it automatically connects and starts ranging. Therefore, I would like to ask what is updated in iOS18 UWB? Is there a document for reference, or can you provide the callback performance of each iOS version for UWB? The code is as follows: niConfiguration = try NINearbyAccessoryConfiguration(data: Data(AccessoryUwbConfigData)) uwbSession.run(niConfiguration)
0
0
480
Dec ’24