【问题标题】:How do I get Google-Maps API working?如何让 Google-Maps API 正常工作?
【发布时间】:2015-09-03 10:28:54
【问题描述】:

我有一个现有的项目,我正在尝试让 Google 地图在其中运行。我遵循了 Google 地图的文档,但它是这样进行的:

在我的项目目录中创建Podfile。它包含:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
pod 'GoogleMaps'

然后我运行pod install。它给了我两个警告:

    [!] The `My App [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
        - Use the `$(inherited)` flag, or
        - Remove the build settings from the target.

    [!] The `My App [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation
        - Use the `$(inherited)` flag, or
        - Remove the build settings from the target.

我尝试使用$(inherited) 标志,它没有做任何事情。我删除了构建设置,它给了我大约 90 个错误。我正在使用其他一些框架(Parse、Facebook SDK),所以我不认为更改这些标志是一种选择。

然后我使用myApp.xcworkspace 打开项目。

appDelegate.m 中,我添加了#import <GoogleMaps/GoogleMaps.h>Google's tuorial 只是说#import <GoogleMaps.h>,但这就是 Xcode 自动为我填写的内容,它说GoogleMaps.h 没有找到)。然后在我的application: didFinishLaunchingWithOptions: 中添加了[GMSServices provideAPIKey:@"myAPIKey"];

当我尝试运行时,它给了我两个错误:

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

第二行和最后一行都是突出显示的。我已经尝试了通过搜索这些错误可以找到的方法 - 将框架拖到 Link Binary with Libraries(给了我大约 90 个错误),并检查我导入的是.h 而不是.m

有什么想法吗?

【问题讨论】:

    标签: ios objective-c xcode google-maps cocoapods


    【解决方案1】:

    我建议尝试两件事:

    1. 再次执行您对$(inherited) 所做的操作。这是必须的。

    2. 在两个项目设置(您的应用和 pod)中,将 Build Active Architecture Only 更改为 No

    【讨论】:

    • 不起作用,仍然给出相同的两个错误。我只是想确保我正确添加了标志 - 就像这样 i.imgur.com/FJcR2B8.png ?
    • 是的,但它应该用于发布和调试
    • 对。我试过了,只为 armv7 和 armv7s 构建。并使用某些框架的旧版本(在另一个问题上看到它)。我还尝试在 Google 框架中使用 -force_load 代替 -ObjC,但这也不起作用。
    • 按照我的建议进行操作后,警告是否消失了(pod install)?
    • 是的。我放弃了在尝试获取地图 API 之前所做的所有更改,将$(inherited) 添加到两者中,当我执行pod install 时,两个错误没有出现。但是架构错误仍然发生。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 2015-06-02
    • 2013-08-10
    • 1970-01-01
    相关资源
    最近更新 更多