Google 个地方有 objective c 个错误

Google places with objective c errors

你好,我刚刚使用 pods 在我的应用程序中实现了 google 个位置,但是当我尝试 运行 我的应用程序时,我收到了这个错误。

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_GMSPlacesClient", referenced from:
      objc-class-ref in ViewController.o
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是我的 pod 文件:

source 'https://github.com/CocoaPods/Specs.git'
project '/Users/GeorgeYoung/Desktop/Travel/Travel.xcodeproj'
target 'Travel' do
pod 'GooglePlaces'
end

错误似乎来自 AppDelegate.m

[GMSPlacesClient provideAPIKey:@"AIzaSyBYRDTp7U-633XB81qsBeOiVGhokPrc6_M"];

Podfile.lock:

PODS:
  - GoogleMaps/Base (2.4.0)
  - GooglePlaces (2.4.0):
    - GoogleMaps/Base (= 2.4.0)

DEPENDENCIES:
  - GooglePlaces

SPEC CHECKSUMS:
  GoogleMaps: 8436ab5d1c25e36915b2f7416d0c8e3fa2e76c61
  GooglePlaces: aafe5990fa7951e98e078761bbdaaf236d7e0c65

PODFILE CHECKSUM: e564be8d79cfc6ae7b4a4a197ee6149eac7d65d2

COCOAPODS: 1.3.1

您没有链接到包含 GMSPlacesClient 的库,或者您使用错误的体系结构构建了库。

如果库的源代码可用,CocoaPods 非常擅长确保构建正确的架构。在这种情况下,Google Places 库是一个预构建库,因此存在不包含具有正确架构的切片的风险。 file 命令可用于检查库是否包含切片。下一个可能性是不知何故库未包含在 link 中。如果您打开 Xcode 项目而不是 CocoaPods 创建的 Xcode 工作区,就会发生这种情况。检查工作空间是否确实被使用以及 Pod 库是否被 linked 可以用来消除这个问题。最后,如果所有其他方法都失败了(并且 CocoaPods 通常似乎再次正确)确保 'Other Linker Flags' 构建设置包含 -ObjC 设置。这需要从静态库中强制加载某些 Objective-C 符号。

综上所述

  1. 检查预建库是否包含所需的切片
  2. 确保您使用的是工作区而不是项目
  3. 确保 Pod 库包含在 link
  4. 确保在中指定了 -ObjC 'Other Linker Flags'

修改您的 pod 文件:

连播 'GooglePlaces'

连播 'GooglePlacePicker'

连播 'GoogleMaps'