在“调试”>“位置”-CoreLocation和MapKit中模拟位置时出现“编译器错误:无效的库文件”

我正在尝试在使用CoreLocation的Xcode 11模拟器上测试一个应用程序。我想使用模拟器中 Debug> Location 下的“ Freeway Drive”位置选项来测试MapKit折线叠加层。

很遗憾,地图上没有任何行,并且在日志中多次打印了“编译器错误:无效的库文件”。

这似乎不是代码问题,而是更多的Xcode问题。有没有办法解决?用物理设备进行测试非常困难,因为在受限空间中的移动并不会真正被CoreLocation吸收。

谢谢!

maya_smily 回答:在“调试”>“位置”-CoreLocation和MapKit中模拟位置时出现“编译器错误:无效的库文件”

只需定义折线并将其“推送”到您的mapView中: let polyline = MKPolyline(coordinates: locations,count: locations.count) mapView.addOverlays([polyline])

并声明mkMapViewDelegate的功能:

    //MKMapViewDelegate
  func mapView(_ mapView: MKMapView,rendererFor overlay: MKOverlay) -> 
 MKOverlayRenderer 

  {
     if let mapPolyline = overlay as? MKPolyline {
            let polyLineRenderer = MKPolylineRenderer(polyline: mapPolyline)
            polyLineRenderer.strokeColor = .darkGray
            polyLineRenderer.lineWidth = 4.0
            return polyLineRenderer
        }
        fatalError("Polyline Renderer could not be initialized" )

   }

它应该在mapView上显示折线。 我也遇到了编译器错误,请尝试修复它。

最佳 德拉甘

本文链接:https://www.f2er.com/2715552.html

大家都在问