【问题标题】:"Compiler error: Invalid library file" when simulating location in Debug > Location - CoreLocation and MapKit在 Debug > Location - CoreLocation 和 MapKit 中模拟位置时出现“编译器错误:库文件无效”
【发布时间】:2020-05-11 06:01:49
【问题描述】:

我试图在使用 CoreLocation 的 Xcode 11 模拟器上测试应用程序。我想在 Debug > Location 下使用模拟器中的“Freeway Drive”位置选项来测试 MapKit 折线覆盖。

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

这似乎不是代码问题,而更像是 Xcode 问题。有没有办法解决?使用物理设备进行测试非常困难,因为在狭窄空间中的移动并不能真正使用 CoreLocation。

谢谢!

【问题讨论】:

    标签: swift xcode mapkit core-location mkpolyline


    【解决方案1】:

    只需定义折线并将其“推送”到您的 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 上显示折线。 我也有编译器错误并尝试修复它。

    最好的 德拉甘

    【讨论】:

      猜你喜欢
      • 2020-02-15
      • 1970-01-01
      • 2021-12-09
      • 2013-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-12
      • 2020-09-11
      相关资源
      最近更新 更多