mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

LocationProvider' is ambiguous for type lookup in this context

Open rgmyyw opened this issue 2 years ago • 1 comments

step1: MapboxSearch and MapboxMaps are required

import MapboxSearch
import MapboxMaps

step2:

    lazy var locationProvider: AppleLocationProvider = {
        let make = AppleLocationProvider()
        make.setDelegate(self)
        return make
    }()

step3:

 func locationProvider(_ provider: LocationProvider, didUpdateLocations locations: [CLLocation]) {
        if locations.isNotEmpty, let current = locations.first?.coordinate {
            currentLocation.accept(current)
            provider.stopUpdatingLocation()
            logDebug("Location didUpdateLocations: \(current.latitude),\(current.longitude)")
        } else {
            logError("Location fail ...")
        }
    }

    func locationProvider(_ provider: LocationProvider, didUpdateHeading newHeading: CLHeading) {
        logDebug("Location didUpdateHeading: \(newHeading)")
    }

    func locationProvider(_ provider: LocationProvider, didFailWithError error: Error) {
        provider.stopUpdatingLocation()
        logError("Location didFailWithError: \(error.localizedDescription)")
    }

a

An error occurred

'LocationProvider' is ambiguous for type lookup in this context

If you remove one, you won't report the above error

截屏2022-08-01 上午9 34 58

21BD80DD-0799-4E3C-8F76-149B3FB1F405

rgmyyw avatar Aug 01 '22 01:08 rgmyyw

Because LocationProvider is defined in both imported frameworks, you need to include module(framework) name when using it - e.g. MapboxMaps.LocationProvider.

evil159 avatar Aug 03 '22 13:08 evil159