当使用Google Maps SDK for IOS时,Apple Mach-O Linker错误

我正尝试在我的应用中使用Google地图SDK。 到目前为止,我已经链接了所有的框架。 我很确定我已经按照说明添加了相应的-ObjC标志。 但是,当我复制并粘贴他们的代码到我的ViewController.m类,我得到以下错误:

架构i386的未定义符号:
“_OBJC_CLASS _ $ _ GMSCameraPosition”,引用自:FoothillTourViewController.o中的objc-class-ref“_OBJC_CLASS _ $ _ GMSMapView”,引用自:FoothillTourViewController.o中的objc-class-ref“_OBJC_CLASS _ $ _ GMSMarker”,引用自:objc-class-ref在foothillTourViewController.o“_OBJC_CLASS _ $ _ GMSServices”中,引用自:FoothillTourAppDelegate.o中的objc-class-ref ld:找不到体系结构i386的符号clang:error:链接器命令失败,退出代码1(使用-v查看调用)

"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_; } 

任何帮助将不胜感激,因为我花了几个小时试图找出发生了什么。 我猜它是一个愚蠢的错误,但我不能把它的手指。 谢谢!

更新 :这个答案已经过时了。 文档现在告诉你使用CocoaPods而不是手动链接依赖关系。

有关更多信息,请参阅Google Developers Console 。

老解答:

Google Maps SDK要求您链接不less的框架。 他们来了:

  • AVFoundation.framework
  • CoreData.framework
  • CoreLocation.framework
  • CoreText.framework
  • GLKit.framework
  • ImageIO.framework
  • 的libc ++。dylib
  • libicucore.dylib
  • libz.dylib
  • OpenGLES.framework
  • QuartzCore.framework
  • SystemConfiguration.framework

我在这里find了这个清单。

适用于iOS的Google Maps SDK版本1.9.2及更早版本可作为包含静态框架的zip文件提供。 也可以select从CocoaPods窗口安装最新版本。 从版本1.10.0开始,Google Maps SDK for iOS只能通过CocoaPods进行安装。

正如您所说,您正在使用适用于iOS的Google Maps SDK。 然而,看起来你正在为OS X编译,因为这个符号对于Intel处理器i386是未定义的。 (除非你正在为模拟器编译)

该SDK可能不会被编译为模拟器。 您可以通过“file”命令运行SDK二进制文件进行检查。 如果它支持ARM处理器,但不支持i386,则不支持模拟器。 你将不得不改变你的构build标志只编译为armv7 / armv7s处理器。