【问题标题】:Google Maps SDK Tutorial CrashGoogle Maps SDK 教程崩溃
【发布时间】:2014-04-17 22:03:24
【问题描述】:

我正在尝试在我的 iOS 应用程序中设置 Google 地图,但遇到了 InvalidArgumentException 崩溃。

已经有人问过同样的问题了;但是,他们要么没有得到有用的响应,要么给出的响应没有解决问题。

代码直接从谷歌的Getting Started页面复制:

#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];

这是堆栈跟踪(为匿名起见,应用名称已删除):

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

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

【问题讨论】:

  • 将 -ObjC 放在目标上时会出现什么错误?
  • 我收到一堆看起来与 Parse 相关的 Mach-O 错误,我正在将其用于后端。所有这些似乎都与 Facebook 令牌身份验证有关,这很奇怪,因为我的代码中没有任何使用 Facebook 的内容。 Undefined symbols for architecture x86_64: "_FBTokenInformationExpirationDateKey", referenced from: -[PFFacebookTokenCachingStrategy cacheTokenInformation:] in Parse(PFFacebookTokenCachingStrategy.o) 其他 8 个错误看起来或多或少是这样的。
  • 一个简单的问题如何为我指明正确的方向令人惊讶。这是与 Parse 依赖项的冲突。解决方案是要么消除 FB SDK 依赖项,要么只下载 SDK。我选择了后者,因为我不可避免地会在我的应用程序中使用它。感谢您的帮助!
  • 不用担心 Tatonka,我很高兴它有帮助 :)

标签: google-maps-sdk-ios


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多