Getting kclErrorDomain error : 1

Hi, I created an iOS app compatible watchOS app which was running perfectly fine before I updated my Xcode to use iPhone16. But after updating, I started to get kclErrorDomain error: 1 and I am not sure why is it happening after update.

I am trying to use coreLocation module as-

import Foundation
import CoreLocation
import Combine

class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
    private var locationManager = CLLocationManager()
    @Published var location: CLLocation?

    override init() {
        super.init()
        locationManager.delegate = self
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.requestWhenInUseAuthorization()
        locationManager.startUpdatingLocation()
    }

    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        if let location = locations.last {
                self.location = location
                print("Updated location: \(location.coordinate.latitude), \(location.coordinate.longitude)")
            } else {
                print("No locations received")
            }
    }

    func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        print("Failed to find user's location: \(error.localizedDescription)")
    }
}

and I am trying to use it as-

@StateObject private var locationManager = LocationManager()
  guard let currentLocation = locationManager.location else {
            signInError = "Location not available"
            isLoading = false
            return
        }

        let latitude = currentLocation.coordinate.latitude
        let longitude = currentLocation.coordinate.longitude
        
        sendToBackend(email: email, password: password, deviceName: deviceName, deviceModel: deviceModel, deviceIdentifier: deviceIdentifier, latitude: latitude, longitude: longitude)

Can someone help me regarding this?

Error 1 is location access to your app is denied. Have you enabled location services in general and for your app in Settings -> Privacy -> Location Services on your new phone?


Argun Tekant /  DTS Engineer / Core Technologies

Getting kclErrorDomain error : 1
 
 
Q