This is my first post here. Please guide me, if I need to provide more information to answer this post.
I write a simple application, that monitors GPS position (location). I followed Apple documentation for LiveUpdates: https://developer.apple.com/documentation/corelocation/supporting-live-updates-in-swiftui-and-mac-catalyst-apps
My app can monitor location in foreground, background or it can completely stop monitoring location. Background location, if needed, is switched on when application changes scenePhase to .background. But it is in the foreground, that memory leaks occur (according to Instruments/Leaks. Namely Leaks points to the instruction:
let updates = CLLocationUpdate.liveUpdates()
every time I start location and then stop it, by setting updatesStarted to false.
Leaks claims there are 5x leaks there:
Malloc 32 Bytes 1 0x6000002c1d00 32 Bytes libswiftDispatch.dylib OS_dispatch_queue.init(label:qos:attributes:autoreleaseFrequency:target:)
CLDispatchSilo 1 0x60000269e700 96 Bytes CoreLocation 0x184525c64
Malloc 48 Bytes 1 0x600000c8f2d0 48 Bytes Foundation +[NSString stringWithUTF8String:]
NSMutableSet 1 0x6000002c4240 32 Bytes LocationSupport 0x18baa65d4
dispatch_queue_t (serial) 1 0x600002c69c80 128 Bytes libswiftDispatch.dylib OS_dispatch_queue.init(label:qos:attributes:autoreleaseFrequency:target:)
I tried [weak self] in Task, but it doesn't solve the leaks problem and causes other issues, so I dropped it. Anyway, Apple doesn't use it either.
Just in case this is my function, which has been slightly changed comparing to Apple example, to suit my needs:
func startLocationUpdates() {
Task() {
do {
self.updatesStarted = true
let updates = CLLocationUpdate.liveUpdates()
for try await update in updates {
// End location updates by breaking out of the loop.
if !self.updatesStarted {
self.location = nil
self.mapLocation = nil
self.track.removeAll()
break
}
if let loc = update.location {
let locationCoordinate = loc.coordinate
let location2D = CLLocationCoordinate2D(latitude: locationCoordinate.latitude, longitude: locationCoordinate.longitude)
self.location = location2D
if self.isAnchor {
if #available(iOS 18.0, *) {
if !update.stationary {
self.track.append(location2D)
}
} else {
// Fallback on earlier versions
if !update.isStationary {
self.track.append(location2D)
}
}
}
}
}
} catch {
//
}
return
}
}
Can anyone help me locating these leaks?
Maps & Location
RSS for tagLearn how to integrate MapKit and Core Location to unlock the power of location-based features in your app.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello,
Probably a noob question but I can't find any example code around this use case, and really no past questions I could find that address it either.
So, I really love that, when a user taps a POI on the map in my app, the map figures out the right POI every time. Flawless. However, when using .mapFeatureSelectionAccessory, I've tried probably 10-12 iterations, and there doesn't seem to be any way to either:
a) add custom content to the place card that's shown, or
b) replace that place card altogether with a view of my own, or
c) capture the place data but use it in a custom view
I want to be able to leverage the accuracy of Apple's tap gesture detection, but show, for example, only the name of the place, along with buttons and a form I have in a view.
Right now if I'm using .mapFeatureSelectionAccessory, I can't seem to bypass the place card at all.
I'm currently developing an app with mapkit which I may submit to the Swift Student Challenge. So anyways, the app will be used completely offline. I was wondering if there was any way to include very low resolution map tiles with the app files. That way, the app never needs wifi. However, I'm not sure if this is possible, especially since the map would need to be under 20 mb. Thanks.
Topic:
App & System Services
SubTopic:
Maps & Location
A north american map that allows myself and family to drop pins and with those pins upload up to a min video to share w other users. This does not have to have navigation just a basic pin drop on a live map that uploads in real-ish time to share w other users ..... i am stuck at where to start, any suggestions or has anyone already made a version they could share advice ? much appreciated
Topic:
App & System Services
SubTopic:
Maps & Location
I am having a problem with the following scenario.
The user opens the Maps app, then selects a location like a store or restaurant, then tap on share and then on my app.
On iOS 26, my app stopped showing altogether. After changing the NSExtensionActivationRule to TRUEPREDICATE to accept all, I see this difference between the OS versions.
iOS 18.5
(lldb) po extensionContext?.inputItems
▿ Optional<Array<Any>>
▿ some : 1 element
- 0 : <NSExtensionItem: 0x60000000c5d0> - userInfo: {
NSExtensionItemAttachmentsKey = (
"<NSItemProvider: 0x600002930d20> {types = (\n \"public.plain-text\"\n)}",
"<NSItemProvider: 0x600002930c40> {types = (\n \"com.apple.mapkit.map-item\"\n)}",
"<NSItemProvider: 0x600002930bd0> {types = (\n \"public.url\"\n)}"
);
NSExtensionItemAttributedContentTextKey = {length = 329, bytes = 0x7b5c7274 66315c61 6e73695c 616e7369 ... 656e7472 61616c7d };
"com.apple.UIKit.NSExtensionItemUserInfoIsContentManagedKey" = 0;
}
iOS 26
(lldb) po extensionContext?.inputItems
▿ Optional<Array<Any>>
▿ some : 1 element
- 0 : <NSExtensionItem: 0x60000000cbd0> - userInfo: {
NSExtensionItemAttachmentsKey = (
"<NSItemProvider: 0x60000293afb0> {types = (\n \"public.url\"\n)}",
"<NSItemProvider: 0x60000293bf70> {types = (\n \"public.plain-text\"\n)}"
);
"com.apple.UIKit.NSExtensionItemUserInfoIsContentManagedKey" = 0;
}
Please notice how iOS 26 is no longer sending com.apple.mapkit.map-item.
Is there an alternative way to read the info from the map location shared to my app?
Description of the Bug:
Core Location intermittently reports inaccurate location updates, albeit with a high accuracy value. This problem occurs almost exclusively while travelling in metros underground affecting the ability to rely on the framework effectively.
Steps to Reproduce:
The user starts travelling on ground level at point A
The user continues travelling and, after some time, is now underground at point B. A stationary beacon scanned at point B confirms this.
Core Location is observed to deliver a location update with a high-accuracy value but with the coordinates around point A when the user is actually around point B.
Expected Behaviour:
Accurate locations should be delivered at all times. In other words, Core Location should not report location updates with high accuracy when its certainty is low.
We’re building a new subway/bus app at the MTA. Our system includes roughly 300 underground stations, around 150 elevated stations (i.e., above street level), and about 5 at-grade stations (i.e., at street level). We serve roughly 5 million riders a day.
We’re diving deep into Core Location on iOS and have found that the altitude values returned from two fields we’re testing aren’t accurate enough for our use case:
CLLocation.altitude
CMAbsoluteAltitudeData.altitude
We need to reliably distinguish whether a user is:
At street level
On an elevated platform (see attached picture)
On any platform in an underground station — most have a single platform level, but some, like 59 St (see attached), have multiple platforms at different elevations.
These levels typically differ by at least 15 feet, which should in theory be well within the precision range of a properly calibrated barometric pressure sensor.
However, the absolute altitude values we’re seeing from these APIs are often inaccurate and inconsistent — not only compared to ground truth, but also across devices. For example, holding two phones side-by-side frequently yields altitude readings that differ by more than 15 feet. That level of variation makes the data unreliable for our needs.
Please see the below photos for more context.
URLs.md
I want to use MapKit with App Intents, but the map does not show up.(See attached image)
Can anyone help me solve this?
import SwiftUI
import MapKit
struct ContentView: View {
@State private var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 37.334_900,
longitude: -122.009_020),
latitudinalMeters: 750,
longitudinalMeters: 750
)
var body: some View {
VStack {
Map(coordinateRegion: $region).frame(width:300, height:300)
.disabled(true)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
import AppIntents
import SwiftUI
import MapKit
struct test20220727bAppIntentsExtension: AppIntent {
static var title: LocalizedStringResource = "test20220727bAppIntentsExtension"
func perform() async throws -> some IntentResult {
return .result(value: "aaa", view: ContentView())
}
}
struct testShortcuts:AppShortcutsProvider{
@available(iOS 16.0, *)
static var appShortcuts: [AppShortcut]{
AppShortcut(
intent: test20220727bAppIntentsExtension(),
phrases: ["test20220727bAppIntentsExtension" ]
)
}
}
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
App Intents
wwdc2022-10032
wwdc2022-10170
Hello,
I'm encountering a runtime crash when building my visionOS app with Xcode 16.3 for visionOS 2.5. Our existing AppStore/Testflight app is also instantly crashing on visionOS 2.5 when opened but works fine on e.g visionOS 2.4.
The app builds successfully but crashes on launch with this symbol lookup error (slightly adjusted because the forum complained regarding sensitive data):
Symbol not found: _$sSo22CLLocationCoordinate2DVSE12CoreLocationMc
Referenced from: <XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX> /private/var/containers/Bundle/Application/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/MyApp.app/MyApp.debug.dylib
Expected in: <XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX> /usr/lib/swift/libswiftCoreLocation.dylib
dyld config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/usr/lib/libLogRedirect.dylib:/usr/lib/libBacktraceRecording.dylib:/usr/lib/libMainThreadChecker.dylib:/System/Library/PrivateFrameworks/GPUToolsCapture.framework/GPUToolsCapture:/usr/lib/libViewDebuggerSupport.dylib
I've already implemented my own Codable conformance for CLLocationCoordinate2D:
extension CLLocationCoordinate2D: Codable {
// implementation details...
}
This worked fine on previous visionOS/Xcode versions. Has anyone encountered this issue or found a solution?
System details:
macOS version: 15.3.2
Xcode version: 16.3
visionOS target: 2.5
Thank you!
Hello,
I'm experiencing an issue with the Apple Maps URL scheme when using raw latitude and longitude coordinates in the daddr parameter.
Until recently, using a URL like this worked reliably:
https://maps.apple.com/?daddr=37.7749,-122.4194
This would open Apple Maps and show directions from the current location to the specified coordinates.
However, on recent iOS versions, this URL no longer behaves as expected.
We have background location updates enabled in our app that updates the location on our servers to deliver realtime weather alerts. We see that we are receiving these location updates when the app is backgrounded by the user.
However, when the user removes our app from the background using the App Switcher, we no longer see notifications happening. We have the app delegate's "didFinishLaunchingWithOptions" method setup to check for .location in the launch options, and start location tracking immediately.
Is it the intention of the OS to no longer send our app background location updates if the user manually removes our app from the background?
Topic:
App & System Services
SubTopic:
Maps & Location
I am having a problem with the following scenario.
The user opens the Maps app, then selects a location like a store or restaurant, then taps on share and then on my app.
On iOS 26, my app stopped showing as an option to receive the location altogether. After changing the NSExtensionActivationRule to TRUEPREDICATE to accept all, I see this difference between the OS versions.
iOS 18.5
(lldb) po extensionContext?.inputItems
▿ Optional<Array<Any>>
▿ some : 1 element
- 0 : <NSExtensionItem: 0x60000000c5d0> - userInfo: {
NSExtensionItemAttachmentsKey = (
"<NSItemProvider: 0x600002930d20> {types = (\n \"public.plain-text\"\n)}",
"<NSItemProvider: 0x600002930c40> {types = (\n \"com.apple.mapkit.map-item\"\n)}",
"<NSItemProvider: 0x600002930bd0> {types = (\n \"public.url\"\n)}"
);
NSExtensionItemAttributedContentTextKey = {length = 329, bytes = 0x7b5c7274 66315c61 6e73695c 616e7369 ... 656e7472 61616c7d };
"com.apple.UIKit.NSExtensionItemUserInfoIsContentManagedKey" = 0;
}
iOS 26
(lldb) po extensionContext?.inputItems
▿ Optional<Array<Any>>
▿ some : 1 element
- 0 : <NSExtensionItem: 0x60000000cbd0> - userInfo: {
NSExtensionItemAttachmentsKey = (
"<NSItemProvider: 0x60000293afb0> {types = (\n \"public.url\"\n)}",
"<NSItemProvider: 0x60000293bf70> {types = (\n \"public.plain-text\"\n)}"
);
"com.apple.UIKit.NSExtensionItemUserInfoIsContentManagedKey" = 0;
}
Please notice how iOS 26 stopped sending com.apple.mapkit.map-item
Is it no longer possible to get a MKMapItem item out of the extension contents from the Maps app?
I would appreciate any pointers on how to extract the info of the shared location from the Maps app.
Topic:
App & System Services
SubTopic:
Maps & Location
Hi,
I'm building an aftermarket solution to enable Apple Maps to support EV routing for any EV.
I am going through the documentation and found some gaps - does anyone know how the following properties work?
INGetCarPowerLevelStatusIntentResponse - consumptionFormulaArguments
INGetCarPowerLevelStatusIntentResponse - chargingFormulaArguments
Is there a working example that anyone has seen?
Many thanks
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
CarPlay
SiriKit
Maps and Location
App Intents
Hi, I am working on a React Native app and i want to have a latitude longitude of a user in every 15 minutes and want to do something like an api call with it. I want to keep continuing this no matter my app is in background, foreground or in killed state. Is there any way or method through which i can achieve this natively or using React Native?
I have seen examples of conducting an Indoor Survey of an IMDF where it has labels on the map.
This would help.
Our structure is basically a huge hall that gets reconfigured weekly from a horse venue to a car show to a home and garden show.
I was thinking of creating a series of walkways to criss cross the floor and then survey them once done.
It would be nice to have a label of the features on the map. How is this done?
Thank you,
Mele
Topic:
App & System Services
SubTopic:
Maps & Location
我目前在做一个防止设备使用的位置是虚拟的,目前通过苹果的api无法直接判断位置来源于真实或虚拟。请问我该如何去判断它呢?
Topic:
App & System Services
SubTopic:
Maps & Location
I am developing a navigation application. My goal is for this navigation app to also work in the background and provide the user with real-time directional updates. When apps request access to location services, users see a TCC (Transparency, Consent, and Control) prompt. This prompt allows the user to choose under what conditions the app can access location services (for example: “While Using the App”, “Always”, etc.).
If the user selects the “While Using the App” option, can the navigation app still access location in the background and provide directional information to the user? Is something like this technically possible? Does Apple allow this behavior for navigation apps or similar use cases?
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Core Location
Maps and Location
Privacy
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)
Topic:
App & System Services
SubTopic:
Maps & Location
Tags:
Beta
Core Location
Maps and Location
Testing
Hi- I've never posted on here before! But ChatGPT hasn't been helpful with this.
I have a call using MKLocalSearch (i have a waddled down version below)
let region = MKCoordinateRegion(
center: location, // the user's location
span: MKCoordinateSpan(
latitudeDelta: 0.005,
longitudeDelta: 0.005
)
)
let req = MKLocalPointsOfInterestRequest(coordinateRegion: region)
req.pointOfInterestFilter = MKPointOfInterestFilter(including: [.nightlife])
let search = MKLocalSearch(request: req)
I made the latitude and longitude the lowest they can possibly be without throwing an error. Sometimes (and unreliably) when the user's location is at say, a bar, this list will give me like 10 bars that are not even within the region, and exclude the bar that the user is actually present in. How can i make this not the case?
In other words, I just want this to return what I expect: a list of POIs with the category .nightLife within the defined region.
Any help would be appreciated!
I'm building a weather map that shows the rain on the map. I'm able to retrieve PNG images that are used as tiles to put onto the map. I then reload all the tiles on the map with each timeframe (tile set for every 10 minutes).
I'm able to get the map loaded up and I'm able to place the tiles and reload the data for each time slot. I preload all the PNG data needed for the tiles and store that NSData for them in memory so that they are quick for loading and showing on the map.
I have timer's set to reload the overlay with the next set of tiles for each time slot. Giving the view of a moving precipitation map over time (just like you'd see on any weather map.)
I have 12 time slots (timestamps) showing every 10 minutes for the past 2 hours. I have it showing each in sequence and then repeating.
Over time I get a crash with this error as a Thread 1: signal SIGABRT.
Failed to acquire drawable, rendering to temporary texture
validateRenderPassDescriptor:782: failed assertion `RenderPass Descriptor Validation
MTLRenderPassAttachmentDescriptor MTLStoreActionMultisampleResolve store action at attachment 0 requires resolve texture
'
validateRenderPassDescriptor:782: failed assertion `RenderPass Descriptor Validation
MTLRenderPassAttachmentDescriptor MTLStoreActionMultisampleResolve store action at attachment 0 requires resolve texture
'
Through some searching I've discovered that this seems to be console output from Metal. I assume Metal is used for MapKit to render the overlay tiles?
I'm using the same custom overlay where I set the timestamp on it and then tell it to reload. I also reuse the same MKOverlayRenderer as shown here...
- (MKOverlayRenderer*)mapView:(MKMapView*)mapView rendererForOverlay:(id<MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKTileOverlay class]]) {
if (!self.rainRenderer) {
self.rainRenderer = [[MKTileOverlayRenderer alloc] initWithTileOverlay:overlay];
self.rainRenderer.alpha = 0.5;
}
return self.rainRenderer;
}
return nil;
}
And here's the function that reloads the overlay...
- (void) updateRainFrame {
self.currentFrameIndex = (self.currentFrameIndex + 1) % self.timestamps.count;
if ((self.currentFrameIndex >= 0) && (self.timestamps.count > self.currentFrameIndex)) {
NSLog (@"self.currentFrameIndex = %lu", self.currentFrameIndex);
NSString *timestamp = self.timestamps[self.currentFrameIndex];
[self.overlay setTimestamp:timestamp];
[self.rainRenderer reloadData];
}
}
The time it takes to crash seems arbitrary. Sometimes it's very quick. Less than a minute. But usually it's several minutes. 10 or 20 minutes or more. Feels like some sort of race condition that's occurring. Perhaps ARC is not able to release the images for the tiles quick enough for each overlay reload? That's a wild guess but I think it's something more deeper in Metal as I feel I would see other errors related to memory availability.
Some of my searches point to something about MSAA needing to be turned off in Metal to resolve this. However I have no idea how I would do that through MapKit.
Any suggestions? Let me know if there is somehow a way to capture more from the crash to give more insight.