CLLocationManager permission prompt never appears in Swift Playground

I am building a Swift Playgrounds App project on iPad running iPadOS 26.0.1 using the latest version of Swift Playgrounds. I need to access Core Location for a plant location logging app. What I have done: • Created an App project (not a Playground) in Swift Playgrounds • Enabled ‘Core Location When in Use’ in the app capabilities (accessed by tapping the app name) • Implemented a CLLocationManager with CLLocationManagerDelegate • Called manager.requestWhenInUseAuthorization() from .onAppear in a SwiftUI view • Called manager.startUpdatingLocation() immediately after The problem: The location permission prompt never appears when the app runs. The app does not appear in Settings → Privacy & Security → Location Services at all. There are no error messages or crashes — the app simply never requests location access. What I have ruled out: • The capability IS enabled in Swift Playgrounds app settings • The app runs without errors otherwise • This is an App project, not a classic Playground, so it should support capabilities Questions: 1. Is CLLocationManager with requestWhenInUseAuthorization() supported in Swift Playgrounds App projects on iPadOS 26? 2. Has the location authorization API changed in iPadOS 26 in a way that affects Swift Playgrounds? 3. Is there a working code example for Core Location in a Swift Playgrounds App project on iPadOS 26? Any guidance would be greatly appreciated.

Answered by Marka99 in 886503022

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!

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?

Accepted Answer

@Marka99 Welcome!

Thank you for the post. I believe developers are referring to samples where you can observe how to implement that functionality.

https://developer.apple.com/tutorials/sample-apps

Also videos are very helpful in my opinion:

https://developer.apple.com/search/?q=CLLocation

Swift Playgrounds App projects fully support Core Location. Because they compile into real application bundles, they behave exactly like apps built in Xcode. You must provide a "Usage Description" string. In Xcode, this is done in the Info.plist. In Swift Playgrounds, this is done in the App Settings. If this string is blank, the prompt will never appear.

The CLLocationManager instance must be strongly retained in memory. If you declare let manager = CLLocationManager() inside .onAppear, the manager is destroyed the moment the .onAppear closure finishes executing. Do not call startUpdatingLocation() immediately after requesting authorization. Instead, wait for the delegate to confirm you have permission.

Albert
  Worldwide Developer Relations.

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!

CLLocationManager permission prompt never appears in Swift Playground
 
 
Q