IT박스

didFailWithError : Error Domain = kCLErrorDomain Code = 0“작업을 완료 할 수 없습니다.

itboxs 2020. 10. 13. 07:33
반응형

didFailWithError : Error Domain = kCLErrorDomain Code = 0“작업을 완료 할 수 없습니다. (kCLErrorDomain 오류 0.)”


현재 위치를 얻고 싶지만 대신 오류가 발생합니다.

이것은 내 뷰 컨트롤러의 일부입니다.

- (void)viewDidLoad {
    self.locationManager = [[CLLocationManager alloc] init];
    [locationManager setDelegate:self];
    [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
    [locationManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager 
     didUpdateLocations:(NSArray<CLLocation *> *)locations {
    // I would get the latest location here
    // but this method never gets called
}
- (void)locationManager:(CLLocationManager *)manager 
       didFailWithError:(NSError *)error {
    NSLog(@"didFailWithError: %@", error);
}

대리자 메서드 locationManager:didUpdateLocations:가 호출 될 것으로 예상하고 있지만 대신 locationManager:didFailWithError:호출 받고 다음을 인쇄합니다.

didFailWithError: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)" 

  1. 실제로 유효한 WiFi 및 3G 연결이 있는지 확인하십시오.

    ... 그렇다면 :

  2. 설정으로 이동하여 위치 서비스를 재설정하십시오.

  3. 네트워크 설정 재설정

이 문제를 해결해야합니다. 앱 관련이 아닌 기기 / 네트워크 관련입니다. 특히 앱이 위치 서비스에 의존하고 기기가 Wi-Fi 전용이고 사람들이 AppStore에서 부정적인 평가를하는 경우에는 특히 짜증이납니다. 죄송합니다.


시뮬레이터를 사용하는 경우 :

  1. 보도 command + shift + ,엑스 코드는 계획 편집기를 엽니 다
  2. 실행 구성표 선택
  3. 옵션 탭으로 이동
  4. 확인 ✅ Allow Location Simulation
  5. 드롭 다운에서 기본 위치를 선택합니다.

None기본 위치로 선택하면 문제가 발생할 수 있습니다.


이 오류를 무시하고 더 많은 업데이트 또는 다른 오류를 기다리십시오.

위치 관리자에 대한 문서는이 오류가 일시적이라고 말합니다. 즉시 위치를 검색하지 못했음을 알리지 만 계속 시도합니다. "이러한 상황에서는 오류를 무시하고 새 이벤트를 기다릴 수 있습니다." 이것은 정말 골칫거리 인 방법을 사용하는 방법입니다 locationManager:didFailWithError:.-감사합니다 Apple!

Apple Documentation


시뮬레이터를 다시 시작하십시오 (사용중인 것으로 가정).

다른 모든 것을 시도한 후에 이것은 나를 위해 일했습니다.


시뮬레이터를 다시 시작해도 작동하지 않았습니다.

을 통해 모든 것을 지워야했습니다 "iOS Simulator" >> "Reset Content and Settings....


시뮬레이터에서이 오류가 발생했습니다. 디버깅 패널에서 위치 버튼을 클릭하고 위치를 설정하면 문제가 해결되었습니다. (버튼이 파란색인지 확인)

여기에 이미지 설명 입력


나는 같은 문제를 가지고있다. 나는 가능한 설명 / 수정 이이 SO 포스트에서 다루어 졌다고 믿는다 .


시뮬레이터에서 "위치"를 변경하는 것이 효과적이었습니다.

디버그> 위치> (예 : City Bicycle Ride 대신 None이 선택되었습니다)


  1. 시뮬레이터에서 설정> 일반> 재설정> 위치 및 개인 정보 재설정으로 이동하십시오.

  2. 시뮬레이터를 종료하고 앱을 다시 실행하십시오.


시뮬레이터를 사용하고 있다고 가정하면 Debug -> Location위치를 설정할 수 있습니다.

선택하지 않은 경우이 오류가 발생합니다.


당신이 custom location올바른 길과 위도를 가지고 있는지 확인 하고 있다면 , 나는 그것을 뒤집어서 깨 달기 전에 3 시간을 낭비했습니다 ...


이전에 문제를 본 적이 있지만 해결 방법이 있지만 한 번만 작동 할 수 있습니다. 프로젝트를 다시 실행하려면 매번 솔루션을 반복해야합니다.

1. Xcode, Product-> Scheme-> Scheme 편집에서 "Allow Location Simulator"를 취소합니다.

2. iOS 시뮬레이터로 이동하여 콘텐츠 및 설정을 재설정합니다.

3. Xcode에 대해 다시 첫 번째 단계를 반복합니다.

4. iOS 시뮬레이터로 이동하여 재설정합니다. 그러면 작동합니다.


이와 같은 문제는 위치를 " Apple" 로 설정하여 해결할 수 있습니다 . 적어도 테스트 목적으로 작동합니다.


  1. 콘텐츠 및 설정을 재설정했습니다.
  2. 파생 데이터에서 데이터를 제거했습니다.
  3. Xcode와 Simulator를 다시 시작하고 나를 위해 일했습니다.

from the answer of @Mem and many others thanks


For returned devs :) Just select "Debug->Location->Freeway Drive" from the Simulator menu. If still problem then try after doing "Simulator->Reset Content and Settings" form the simulator menu. This helped me once with the same issue. Some time simulator location is set to "Custom location" due to which its not detecting anything.


Try in device. Sometimes simulator fails to take your location.


Go to home in simulator

home ->Settings ->Privacy ->Locations -> select the app and choose always


when adding permission Privacy - Location When In Use Usage Description in the info.plist it was solved for me


If you are using the Simulator, make sure the scheme allows location, and you picked a default location.

여기에 이미지 설명 입력

참고 URL : https://stackoverflow.com/questions/6032976/didfailwitherror-error-domain-kclerrordomain-code-0-the-operation-couldn-t-be

반응형