Post

Replies

Boosts

Views

Activity

Reply to CLLocationManager permission prompt never appears in Swift Playground
Solved! Thank you to everyone who responded. The issue: The location permission prompt never appeared when requestWhenInUseAuthorization() was called from within a SwiftUI sheet (modal view). iOS silently ignores permission requests made from inside sheets. The fix: Move the permission request to the parent view’s .onAppear modifier — before any sheet is presented. The LocationManager is created as a @StateObject in the main ContentView, requestPermission() is called in ContentView.onAppear, and the LocationManager instance is passed into the sheet view as an @ObservedObject. Key points: • The Core Location When in Use capability must be enabled in Swift Playgrounds app settings • Use @StateObject in the parent view, @ObservedObject in the sheet • Call requestWhenInUseAuthorization() from the main view, not from inside a sheet • startUpdatingLocation() can still be called from within the sheet’s .onAppear Hope this helps someone else!
May ’26
Reply to CLLocationManager permission prompt never appears in Swift Playground
A suggestion from the Swift community was to look at Apple’s sample CoreLocation app in Swift Playgrounds for guidance on where to add the location usage description string. However in Swift Playgrounds on iPadOS 26 we cannot find a sample gallery or sample apps — only ‘New Playground’ and ‘Learn to Code’ options are available. Has the sample gallery been removed in the latest version, and is there an alternative way to access Apple’s CoreLocation sample for Swift Playgrounds?
May ’26
Reply to CLLocationManager permission prompt never appears in Swift Playground
Solved! Thank you to everyone who responded. The issue: The location permission prompt never appeared when requestWhenInUseAuthorization() was called from within a SwiftUI sheet (modal view). iOS silently ignores permission requests made from inside sheets. The fix: Move the permission request to the parent view’s .onAppear modifier — before any sheet is presented. The LocationManager is created as a @StateObject in the main ContentView, requestPermission() is called in ContentView.onAppear, and the LocationManager instance is passed into the sheet view as an @ObservedObject. Key points: • The Core Location When in Use capability must be enabled in Swift Playgrounds app settings • Use @StateObject in the parent view, @ObservedObject in the sheet • Call requestWhenInUseAuthorization() from the main view, not from inside a sheet • startUpdatingLocation() can still be called from within the sheet’s .onAppear Hope this helps someone else!
Replies
Boosts
Views
Activity
May ’26
Reply to CLLocationManager permission prompt never appears in Swift Playground
A suggestion from the Swift community was to look at Apple’s sample CoreLocation app in Swift Playgrounds for guidance on where to add the location usage description string. However in Swift Playgrounds on iPadOS 26 we cannot find a sample gallery or sample apps — only ‘New Playground’ and ‘Learn to Code’ options are available. Has the sample gallery been removed in the latest version, and is there an alternative way to access Apple’s CoreLocation sample for Swift Playgrounds?
Replies
Boosts
Views
Activity
May ’26