iOS - 当试图阅读 bundle.man.url 时 return 什么都没有

iOS - When trying to read bundle.man.url doesn't return anything

我正在尝试从我的 geoJSON 文件中添加一个 boundary,我正在使用 GEOSwift 窗格。但是当我 运行 项目时,它总是打印 "Unable to load geoJSON data, could not find such file." 消息,这意味着出了点问题。

P.S geoJSON 文件可以找到 here。我正在使用 swift 3.

func addBoundry() {
        print("1")
        if let geoJSONURL = Bundle.main.url(forResource: "multipolygon", withExtension: "geojson") {
            print("2")
            do {
                print("3")
                let geometries = try Geometry.fromGeoJSON(geoJSONURL)
                if let geo = geometries?[0] as? MultiPolygon {
                    print("4")

                    if let shapesCollection = geo.mapShape() as? MKShapesCollection {
                        print("5")

                        let shapes = shapesCollection.shapes

                        for shape in shapes {
                            print("6")
                            if let polygon = shape as? MKPolygon {
                                print("7")
                                mapView.add(polygon)
                            }
                        }
                    }
                }
            } catch {
                print("Unable to load geojson data")
            }
        } else {
            print("Unable to load geojson data, could not find such file.")
        }
    }

提前致谢!

确保 "multipolygon.geojson" 文件是构建目标的一部分。

Select 文件并确保在 "Target Membership" 下的身份检查器([=18= 的右栏],顶部的小页面图标)中检查了您正在构建的目标。它也应该列在目标的构建阶段(select 导航器中的项目,然后是主窗格中的相关目标,然后是顶部的 "Build Phases"),在 "Copy Bundle Resources" 下。