谷歌地图SDK教程崩溃



我正试图在iOS应用程序中设置谷歌地图,但遇到InvalidArgumentException。

一些人已经提出了同样的问题;然而,他们要么没有得到有用的回应,要么给出的回应没有解决问题。

代码直接从谷歌的入门页面复制:

#import "XXMapViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@interface XXMapViewController ()
@end
@implementation XXMapViewController{
    GMSMapView *mapView_;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    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_;
    // Do any additional setup after loading the view, typically from a nib.

}
@end

这是它崩溃的线路,所以我已经确定设置视图没有问题:

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

这是堆栈跟踪(为了匿名起见,应用程序名称为X’d out):

2014-04-17 14:24:19.909 XX App[28758:60b] -[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10ae45a80
2014-04-17 14:24:19.931 XX App[28758:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance 0x10ae45a80'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103b2b495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010388a99e objc_exception_throw + 43
    2   CoreFoundation                      0x0000000103bbc65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000103b1cd8d ___forwarding___ + 973
    4   CoreFoundation                      0x0000000103b1c938 _CF_forwarding_prep_0 + 120
    5   XX        App                       0x0000000100189323 -[GMSMapView setCamera:] + 161
    6   XX        App                       0x0000000100187cc2 -[GMSMapView sharedInitWithServices:camera:] + 1440
    7   XX        App                       0x00000001001870be -[GMSMapView initWithFrame:camera:] + 121
    8   XX        App                       0x0000000100186f5f +[GMSMapView mapWithFrame:camera:] + 102
    9   XX        App                       0x000000010000eeae -[XXMapViewController viewDidLoad] + 238
    10  UIKit                               0x000000010252d59e -[UIViewController loadViewIfRequired] + 562
    11  UIKit                               0x000000010252d777 -[UIViewController view] + 29
    12  UIKit                               0x00000001025442c5 -[UINavigationController _startCustomTransition:] + 628
    13  UIKit                               0x000000010254f6f5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 401
    14  UIKit                               0x0000000102550238 -[UINavigationController __viewWillLayoutSubviews] + 43
    15  UIKit                               0x000000010266a895 -[UILayoutContainerView layoutSubviews] + 202
    16  UIKit                               0x0000000102497993 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
    17  QuartzCore                          0x0000000100e77802 -[CALayer layoutSublayers] + 151
    18  QuartzCore                          0x0000000100e6c369 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
    19  QuartzCore                          0x0000000100e6c1ea _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    20  QuartzCore                          0x0000000100ddffb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
    21  QuartzCore                          0x0000000100de1030 _ZN2CA11Transaction6commitEv + 394
    22  QuartzCore                          0x0000000100de169d _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
    23  CoreFoundation                      0x0000000103af6dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    24  CoreFoundation                      0x0000000103af6d37 __CFRunLoopDoObservers + 391
    25  CoreFoundation                      0x0000000103ad6522 __CFRunLoopRun + 946
    26  CoreFoundation                      0x0000000103ad5d83 CFRunLoopRunSpecific + 467
    27  GraphicsServices                    0x000000010491cf04 GSEventRunModal + 161
    28  UIKit                               0x0000000102437e33 UIApplicationMain + 1010
    29  XX        App                       0x000000010000ed93 main + 115
    30  libdyld.dylib                       0x000000010434c5fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我已经将-OjC标志添加到我的项目中,并按照其他人的建议尝试将其添加到目标中;但是,将其添加到目标会导致构建失败。我还创建了一个新的单视图项目,当遵循完全相同的说明时,它运行良好。我有正确的API密钥,iOS版谷歌地图在我的API控制台中启用。这非常令人沮丧,是我完成项目的一堵巨大的墙。如果有人能给我指明正确的方向,我将不胜感激

这是与Parse依赖项的冲突。解决方案是要么消除FB SDK依赖项,要么只下载SDK。我选择了后者,因为我将不可避免地在我的应用程序中使用它。

最新更新