首页 > 解决方案 > 使用未声明类型 GMSPlacesField GoogleMaps SDK Swift

问题描述

使用 GooglePlaces 自动完成 UI 时出现错误 Use of undeclared type 'GMSPlacefield'。

我在这里搜索 GMSPlaceField Error when building - Swift 4.2

我已经尝试更新我正在使用 google places 3.1.0 和 google maps 3.1.0 的 pod 文件。我已经重新启动了干净的构建。

我认为代码是很好的代码,因为它在谷歌文档的多个地方使用。 https://woolpert-googlecloud.github.io/maps-platform-b​​est-practices/docs/place-details-fields.html

失败的特定代码行是 let fields:GMSPlaceField = GMSPlaceField(rawValue: UInt(GMSPlaceField.name.rawValue) | UInt(GMSPlaceField.placeID.rawValue))!

编译器指示使用未声明的类型 'GMSPlaceField'

标签: swiftxcodegoogle-mapsgoogleplacesautocomplete

解决方案


尝试更新 Pod 文件时。我得到了执行 CocoaPods 安装安装 GoogleMaps (3.1.0) 安装 GooglePlaces (3.1.0) Pod 安装完成的报告!Podfile 中有 2 个依赖项,总共安装了 2 个 pod。

但这在复活时不是真的,这表明我仍然在 2.7.0。

我更新了 pod 文件以专门调出最近的 pod 文件 pod 'GooglePlaces', '~> 3.1' pod 'GoogleMaps', '~> 3.1'

这有效并解决了问题。


推荐阅读