tundsdev
tundsdev

Reputation: 21

iOS 17.0.1 Simulator Doesn't Show Custom App Settings When Requesting Location Permission Access

I may have found a bug within Xcode 15.0.1. I am working with CoreLocation in order to access a user's location. I have all the code working and the permissions needed within the info.plist. Below is a checklist of everything that I have. Info.plist

I don't need to but I added all 3 keys into my project's info.plist to explain the reason why I need access to the user's location:

This was just to cover all basis.

Requesting Permission

After doing that I have a simple class that requests access to the users location.

@Observable
class LocationPermissionManager: NSObject {
    
    private let manager = CLLocationManager()
    
    override init() {
        super.init()
        manager.delegate = self
    }
    
    func requestAuthorisation() {
        manager.requestWhenInUseAuthorization()
    }
}

Nothing too wild just a simple class to ask for authorisation permission. When I create an instance of this class and call the function to request authorisation. I get the system dialogue to ask for permission and I'm able to select an option.

The Problem The issue starts to happen after. When I go to the settings on the simulator the app doesn't show up or appear. But if I go to the settings on my actual iPhone the app does show up and appear and i'm able to change the different permissions you want to give the app.

Requesting Permission Something weird I did find is a work around to make your app appear in the settings. And it involves you requesting permission for another API i.e ATT (App Tracking Transparency) this does work and you're able to see your app appear in the settings on the simulator and you'll see both the ATT & Location permission options as well.

It's worth nothing that I'm using SwiftUI for this and this possible bug might be a big one since if someone doesn't have a physical iPhone they're not able to change the permissions for their location on the simulator. Could someone in Apple please investigate this issue?

I have tried the following to try and resolve the issue

Upvotes: 0

Views: 679

Answers (1)

Hean Le Villageois
Hean Le Villageois

Reputation: 21

You forgot to init the requestWhenInUseAuthorization in the init().

@Observable
class LocationPermissionManager: NSObject {
    
    private let manager = CLLocationManager()
    
    override init() {
        super.init()
        manager.delegate = self
manager.requestWhenInUseAuthorization() // MARK: Requesting Location access
    }
    
    func requestAuthorisation() {
        manager.requestWhenInUseAuthorization()
    }
}

You have to implement the locationManagerDidChangeAuthorization method:

    //MARK: Location Authorization
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
    switch manager.authorizationStatus {
    case .authorizedAlways:manager.requestLocation()
    case .notDetermined: manager.requestWhenInUseAuthorization()
    case .authorizedWhenInUse:manager.requestLocation()
    case .restricted:manager.requestLocation()
    case .denied: 
//Handle Error
        
    default:()
        
    }
}

It should be done

Upvotes: 0

Related Questions