GoogleMaps基本的iOS演示程序崩溃 – 无法识别的select器发送到实例

我试图运行基本的iOS演示SDK代码。 我已经创build了API密钥,并且可以正常加载。 虽然我已经将代码从viewDidLoad转移到loadView,但效果依然存在。 看下面的代码

-(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; } 

相机被创build,但执行此行时

 _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 

抛出一个NSException与描述 – > – [GMSMapView animateToCameraPosition:]:无法识别的select器发送到实例。

*终止应用程序由于未捕获的exception'NSInvalidArgumentException',原因是: ' – [GMSMapView中animateToCameraPosition:]:无法识别的select发送到实例0x14dbb870' *第一掷调用堆栈:(0x2f462f4b 0x39cd96af 0x2f4668e7 0x2f4651cb 0x2f3b44d8 0x4cebe9 0x4cd78f 0x4ccc41 0x4ccb3d 0x21ced5 0x31bda1bd 0x31bda139 0x1d4b27 0x1d4a83 0x1d51cd 0x31bda37b 0x31c850f1 0x31c85007 0x31c845e3 0x31c8430d 0x31c8407d 0x31c84015 0x31bd5da3 0x3185cc6b 0x3185847b 0x3185830d 0x31857d1f 0x31857b2f 0x31bce0c3 0x2f42e1cd 0x2f42bb71 0x2f42beb3 0x2f396c27 0x2f396a0b 0x34097283 0x31c3a049 0xf58b1 0x3a1e1ab7)的libc ++ abi.dylib:与typesNSException的未捕获的exception终止

我想你可能已经忘记让这个类成为一个GMSMapView委托。 ()之后的GMSMapViewDelegate位需要在<>之间

我不分配该代表以及谷歌基本代码不分配它。 我很幸运地设法使它工作。 谷歌地图上的谷歌文档声明如下:

select你的项目,而不是一个特定的目标,并打开生成设置选项卡。 在Other Linker Flags部分中,添加-ObjC。 如果这些设置不可见,请将“生成设置”栏中的filter从“基本”更改为“全部”。

但是他们的例子项目,经过我的检查,已经把目标设定了。 设置它在我的项目中的构build目标在我的情况帮助和我的发布的代码工作正常。

在项目的GoTo中添加-ObjC:点击Project-> Targets-> Build Setting-> search(Other Linker Flags) – > Set(-ObjC)请参考屏幕截图: 连接器标志

你可能已经忘记这么做了:(如google文档所述)

select你的项目,而不是一个特定的目标,并打开生成设置选项卡。 在Other Linker Flags部分中,添加-ObjC。 如果这些设置不可见,请将“生成设置”栏中的filter从“基本”更改为“全部”。

我有同样的错误,因为我错误地写了-objC而不是-ObjC(大写字母O)

如果有帮助的话

请注意,您应该将-ObjC添加到项目中的“其他链接器标志”部分….不在您的特定目标中。

其他人提到了Google文档中的以下部分

select你的项目,而不是一个特定的目标,并打开生成设置选项卡。 在Other Linker Flags部分中,添加-ObjC。 如果这些设置不可见,请将“生成设置”栏中的filter从“基本”更改为“全部”。

然而,直到我将-ObjC标志添加到项目的“其他链接标志”部分,而不是目标的“其他链接标志”部分,才能够解决无法识别的select器错误。

我想你可能已经忘记让这个类成为一个GMSMapView委托。 ()之后的GMSMapViewDelegate位需要在<>之间

 @interface StructuredGeocoderViewController () GMSMapViewDelegate @end @implementation StructuredGeocoderViewController { GMSMapView *_mapView; GMSGeocoder *_geocoder; } - (void)viewDidLoad { [super viewDidLoad]; GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868 longitude:151.2086 zoom:12]; _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; _mapView.delegate = self; _geocoder = [[GMSGeocoder alloc] init]; self.view = _mapView; } 

当你想把它提交给商店或testing航class也把标志-ObjC在发布 在这里输入图像说明