xcode 使用适用于 IOS 的 Google Maps SDK 时出现 Apple Mach-O 链接器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18027229/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apple Mach-O Linker Error when using Google Maps SDK for IOS
提问by Arjun Nijhawan
I am trying to use the Google Maps SDK in my app. So far, I have linked all the frameworks. I am pretty sure I have added the appropriate -ObjC
flags as per the instructions. However, when I copied and pasted their code into my ViewController.m
class, I get the following errors:
我正在尝试在我的应用中使用 Google Maps SDK。到目前为止,我已经链接了所有框架。我很确定我已经-ObjC
按照说明添加了适当的标志。但是,当我将他们的代码复制并粘贴到我的ViewController.m
班级中时,出现以下错误:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_GMSCameraPosition", referenced from: objc-class-ref in FoothillTourViewController.o "_OBJC_CLASS_$_GMSMapView", referenced from: objc-class-ref in FoothillTourViewController.o "_OBJC_CLASS_$_GMSMarker", referenced from: objc-class-ref in FoothillTourViewController.o "_OBJC_CLASS_$_GMSServices", referenced from: objc-class-ref in FoothillTourAppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
体系结构 i386 的未定义符号:
“_OBJC_CLASS_$_GMSCameraPosition”,引用自:FoothillTourViewController.o 中的 objc-class-ref “_OBJC_CLASS_$_GMSMapView”,引用自:FoothillTourViewController.o 中的 objc-class-ref,“_OBJC_GMSCameraPosition”,引用自:FoothillTourViewController.o 中的 objc-class-ref :FoothillTourViewController.o“_OBJC_CLASS_$_GMSServices”中的objc-class-ref,引用自:FoothillTourAppDelegate.o ld中的objc-class-ref:找不到架构i386 clang的符号:错误:链接器命令失败,退出代码1 (使用 -v 查看调用)
"FoothillTourViewController"
is the name of my ViewController
class.
Here is the code for my View Controller class. The code is taken straight from the instructions.
"FoothillTourViewController"
是我ViewController
班级的名字。这是我的 View Controller 类的代码。代码直接取自说明。
#import "FoothillTourViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@implementation FoothillTourViewController {
GMSMapView *mapView_;
}
// You don't need to modify the default initWithNibName:bundle: method.
- (void)loadView {
//Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
}
Any help would be greatly appreciated as I have been spending hours trying to figure out what is happening. I'm guessing its a stupid mistake, but I can't put my finger on it. Thanks!
任何帮助将不胜感激,因为我一直在花费数小时试图弄清楚发生了什么。我猜这是一个愚蠢的错误,但我不能把我的手指放在它上面。谢谢!
回答by whoKnows
UPDATE: this answer is outdated. The documentation now tells you to use CocoaPods instead of manually linking dependencies.
更新:此答案已过时。文档现在告诉您使用 CocoaPods 而不是手动链接依赖项。
For more information, see Google Developers Console.
有关更多信息,请参阅Google Developers Console。
OLD ANSWER:
旧答案:
The Google Maps SDK requires you to link quite a few frameworks. Here they are:
Google Maps SDK 需要您链接相当多的框架。他们来了:
- AVFoundation.framework
- CoreData.framework
- CoreLocation.framework
- CoreText.framework
- GLKit.framework
- ImageIO.framework
- libc++.dylib
- libicucore.dylib
- libz.dylib
- OpenGLES.framework
- QuartzCore.framework
- SystemConfiguration.framework
- AVFoundation.framework
- 核心数据框架
- 核心位置框架
- 核心文本框架
- GLKit.framework
- ImageIO.framework
- libc++.dylib
- libicucore.dylib
- 动态库
- OpenGLES.framework
- QuartzCore.framework
- 系统配置框架
I found this list at here.
我在这里找到了这个列表。
回答by Frank
Versions 1.9.2 and earlier of the Google Maps SDK for iOS were available as a zip file containing a static framework. There was also the option to install recent versions from a CocoaPods pod. From version 1.10.0 onwards, the Google Maps SDK for iOS is available for installation only via CocoaPods.
适用于 iOS 的 Google Maps SDK 1.9.2 及更早版本以包含静态框架的 zip 文件形式提供。还可以选择从 CocoaPods pod 安装最新版本。从 1.10.0 版本开始,iOS 版 Google Maps SDK 只能通过 CocoaPods 安装。
回答by eswick
As you said, you're using the Google Maps SDK for iOS. Yet, it looks like you are compiling for OS X, as the symbols are undefined for i386, an Intel processor. (Unless you are trying to compile for the simulator)
正如您所说,您使用的是 iOS 版 Google Maps SDK。但是,看起来您正在为 OS X 进行编译,因为 i386(英特尔处理器)的符号未定义。(除非您尝试为模拟器编译)
The SDK may not be compiled for the simulator. You can check by running the SDK binary through the "file" command. If it has support for ARM processors, but not i386, it doesn't have support for the simulator. You'll have to change your build flags to only compile for armv7/armv7s processors.
可能不会为模拟器编译 SDK。您可以通过“file”命令运行 SDK 二进制文件进行检查。如果它支持 ARM 处理器,但不支持 i386,则它不支持模拟器。您必须将构建标志更改为仅针对 armv7/armv7s 处理器进行编译。