【问题标题】:Use of unresolved identifier 'GMSPlacesClient' in xcode 7.3.1在 xcode 7.3.1 中使用未解析的标识符“GMSPlacesClient”
【发布时间】:2016-08-05 06:34:29
【问题描述】:
func searchBar(searchBar: UISearchBar,
    textDidChange searchText: String){

        let placesClient = GMSPlacesClient()
        placesClient.autocompleteQuery(searchText, bounds: nil, filter: nil) { (results, error:NSError?) -> Void in
            self.resultsArray.removeAll()
            if results == nil {
                return
            }
            for result in results!{
                if let result = result as? GMSAutocompletePrediction{
                    self.resultsArray.append(result.attributedFullText.string)
                }
            }
            self.searchResultController.reloadDataWithArray(self.resultsArray)
        }
}

我用这种方法在谷歌地图中搜索地址。但是发现Use of unresolved identifier 'GMSPlacesClient' 错误。我该如何解决这个问题?

【问题讨论】:

  • 你在这个视图控制器中导入了谷歌地图吗?
  • import GoogleMaps 是的,我导入这个。
  • 基本上它在通过 cocoapds 安装 Almofire 之前工作正常。但是当我在 pod 中添加 almofire 时,我会更新 pod 这个错误。
  • 移除 use_framework!然后再次安装 pod
  • 我再次安装 pod 但同样的问题

标签: ios swift google-maps


【解决方案1】:

如果使用 cocoapod,您需要添加 pod 'GooglePlaces'。 并导入 GooglePlaces。

【讨论】:

    【解决方案2】:

    Use of unresolved identifier 'GMSPlacesClient' 错误可能发生在您的新类具有与另一个不同的目标时。在这个thread 中声明它可能有一个测试目标,而另一个没有。对于这种情况,您必须将所有类包含在测试目标中,或者一个都不包含。

    这个blog 也提供了错误的可能解决方案,“使用未解析的标识符”。将班级的访问控制更改为公开。此外,还要标记您打算使用 public 测试的任何方法。还尝试将您希望能够为其编写单元测试的类添加到测试目标。

    您也可以查看此related SO question。希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-12
      相关资源
      最近更新 更多