iOS GoogleMaps SDK error: “[__NSCFDictionary objectForKeyedSubscript:]: Unrecognized selector sent”

你说的曾经没有我的故事 提交于 2019-12-23 22:25:38

问题


I follow every step in getting started with google maps for ios, I did everything ok but in every example that I try, the emulator start asking if I want turn on the GPS and after that, it throws the error:

2013-03-07 16:05:09.135 Cicerone4all[352:14e03] Google Maps SDK for iOS version: 1.1.0.2080
2013-03-07 16:05:09.750 Cicerone4all[352:10d03] -[__NSCFDictionary objectForKeyedSubscript:]: unrecognized selector sent to instance 0xcac9b40
2013-03-07 16:05:09.755 Cicerone4all[352:10d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectForKeyedSubscript:]: unrecognized selector sent to instance 0xcac9b40'
*** First throw call stack:
(0x24a5022 0x2636d0a 0x24a6cbd 0x240bed0 0x240bcb2 0xc7d21 0x14ea9e 0x14dc05 0x15f0a6 0x15ce9e 0x1606d7 0xe5e64 0x132a43 0x131842 0x7f312f 0x7f3003 0x2479936 0x24793d7 0x23dc790 0x23dbd84 0x23dbc9b 0x2d3a7d8 0x2d3a88a 0x14dea16 0x270d 0x2675)
terminate called throwing an exception(lldb) 

AppDelegate:

#import "AppDelegate.h" 
#import "ViewController.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [GMSServices provideAPIKey:@"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

@end

ViewController:

#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>
@interface ViewController ()

@end

@implementation ViewController{
    GMSMapView *mapView_;
}

- (void)loadView {
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
                                                            longitude:151.2086
                                                                 zoom:6];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView_.myLocationEnabled = YES;
    self.view = mapView_;

    GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init];
    options.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
    options.title = @"Sydney";
    options.snippet = @"Australia";
    [mapView_ addMarkerWithOptions:options];
}

@end

Stack trace:

UIKit`UIApplicationMain:

0x14de58b:  pushl  %ebp
0x14de58c:  movl   %esp, %ebp
0x14de58e:  pushl  %ebx
0x14de58f:  pushl  %edi
0x14de590:  pushl  %esi
0x14de591:  subl   $44, %esp
0x14de594:  calll  0x014de599               ; UIApplicationMain + 14
0x14de599:  popl   %eax
0x14de59a:  movl   %eax, -16(%ebp)
0x14de59d:  movl   $1, (%esp)
0x14de5a4:  calll  0x014dbc6e               ; _UIApplicationLinkedOnOrAfter
0x14de5a9:  xorl   %ecx, %ecx
0x14de5ab:  testb  %al, %al
0x14de5ad:  je     0x014de5de               ; UIApplicationMain + 83
0x14de5af:  movl   -16(%ebp), %esi
0x14de5b2:  movl   6976791(%esi), %eax
0x14de5b8:  movl   6929119(%esi), %ecx
0x14de5be:  movl   %ecx, 4(%esp)
0x14de5c2:  movl   %eax, (%esp)
0x14de5c5:  calll  0x0198790a               ; objc_msgSend
0x14de5ca:  movl   6929295(%esi), %ecx
0x14de5d0:  movl   %ecx, 4(%esp)
0x14de5d4:  movl   %eax, (%esp)
0x14de5d7:  calll  0x0198790a               ; objc_msgSend
0x14de5dc:  movl   %eax, %ecx
0x14de5de:  movl   %ecx, -20(%ebp)
0x14de5e1:  movl   8(%ebp), %edi
0x14de5e4:  cmpl   $2, %edi
0x14de5e7:  jl     0x014de659               ; UIApplicationMain + 206
0x14de5e9:  movl   12(%ebp), %ebx
0x14de5ec:  addl   $4, %ebx
0x14de5ef:  decl   %edi
0x14de5f0:  movl   (%ebx), %esi
0x14de5f2:  movl   -16(%ebp), %eax
0x14de5f5:  leal   5455388(%eax), %eax
0x14de5fb:  movl   %eax, 4(%esp)
0x14de5ff:  movl   %esi, (%esp)
0x14de602:  calll  0x01987a3c               ; strcmp
0x14de607:  testl  %eax, %eax
0x14de609:  jne    0x014de617               ; UIApplicationMain + 140
0x14de60b:  movl   -16(%ebp), %eax
0x14de60e:  movb   $1, 7181316(%eax)
0x14de615:  jmp    0x014de653               ; UIApplicationMain + 200
0x14de617:  movl   -16(%ebp), %eax
0x14de61a:  leal   5450169(%eax), %eax
0x14de620:  movl   %eax, 4(%esp)
0x14de624:  movl   %esi, (%esp)
0x14de627:  calll  0x01987a3c               ; strcmp
0x14de62c:  testl  %eax, %eax
0x14de62e:  je     0x014de649               ; UIApplicationMain + 190
0x14de630:  movl   -16(%ebp), %eax
0x14de633:  leal   5450194(%eax), %eax
0x14de639:  movl   %eax, 4(%esp)
0x14de63d:  movl   %esi, (%esp)
0x14de640:  calll  0x01987a3c               ; strcmp
0x14de645:  testl  %eax, %eax
0x14de647:  jne    0x014de653               ; UIApplicationMain + 200
0x14de649:  movl   -16(%ebp), %eax
0x14de64c:  movb   $1, 7181319(%eax)
0x14de653:  addl   $4, %ebx
0x14de656:  decl   %edi
0x14de657:  jne    0x014de5f0               ; UIApplicationMain + 101
0x14de659:  movl   16(%ebp), %ebx
0x14de65c:  calll  0x014e1026               ; UIApplicationInitialize
0x14de661:  movl   -16(%ebp), %edx
0x14de664:  movl   6976747(%edx), %eax
0x14de66a:  movl   6928967(%edx), %ecx
0x14de670:  movl   %edx, %esi
0x14de672:  movl   %ecx, 4(%esp)
0x14de676:  movl   %eax, (%esp)
0x14de679:  calll  0x0198790a               ; objc_msgSend
0x14de67e:  movl   %eax, %edi
0x14de680:  testl  %ebx, %ebx
0x14de682:  jne    0x014de6cc               ; UIApplicationMain + 321
0x14de684:  movl   6976767(%esi), %eax
0x14de68a:  movl   6929687(%esi), %ecx
0x14de690:  movl   %ecx, 4(%esp)
0x14de694:  movl   %eax, (%esp)
0x14de697:  calll  0x0198790a               ; objc_msgSend
0x14de69c:  movl   6929695(%esi), %ecx
0x14de6a2:  movl   %ecx, 4(%esp)
0x14de6a6:  movl   %eax, (%esp)
0x14de6a9:  calll  0x0198790a               ; objc_msgSend
0x14de6ae:  movl   6929699(%esi), %ecx
0x14de6b4:  leal   7032327(%esi), %edx
0x14de6ba:  movl   %edx, 8(%esp)
0x14de6be:  movl   %ecx, 4(%esp)
0x14de6c2:  movl   %eax, (%esp)
0x14de6c5:  calll  0x0198790a               ; objc_msgSend
0x14de6ca:  movl   %eax, %ebx
0x14de6cc:  movl   6929707(%esi), %eax
0x14de6d2:  movl   %eax, 4(%esp)
0x14de6d6:  movl   %ebx, (%esp)
0x14de6d9:  calll  0x0198790a               ; objc_msgSend
0x14de6de:  testl  %eax, %eax
0x14de6e0:  je     0x014de78e               ; UIApplicationMain + 515
0x14de6e6:  movl   %ebx, (%esp)
0x14de6e9:  calll  0x01987214               ; NSClassFromString
0x14de6ee:  movl   %eax, %edi
0x14de6f0:  testl  %edi, %edi
0x14de6f2:  jne    0x014de78e               ; UIApplicationMain + 515
0x14de6f8:  movl   6976639(%esi), %eax
0x14de6fe:  movl   6928919(%esi), %ecx
0x14de704:  movl   %ecx, 4(%esp)
0x14de708:  movl   %eax, (%esp)
0x14de70b:  calll  0x0198790a               ; objc_msgSend
0x14de710:  movl   %eax, -16(%ebp)
0x14de713:  movl   6976643(%esi), %eax
0x14de719:  movl   6928923(%esi), %ecx
0x14de71f:  leal   5450237(%esi), %edx
0x14de725:  movl   %edx, 8(%esp)
0x14de729:  movl   %ecx, 4(%esp)
0x14de72d:  movl   %eax, (%esp)
0x14de730:  calll  0x0198790a               ; objc_msgSend
0x14de735:  movl   %eax, %edi
0x14de737:  movl   6976643(%esi), %eax
0x14de73d:  movl   6928923(%esi), %ecx
0x14de743:  leal   5448982(%esi), %edx
0x14de749:  movl   %edx, 8(%esp)
0x14de74d:  movl   %ecx, 4(%esp)
0x14de751:  movl   %eax, (%esp)
0x14de754:  calll  0x0198790a               ; objc_msgSend
0x14de759:  movl   6930011(%esi), %ecx
0x14de75f:  movl   %ebx, 24(%esp)
0x14de763:  leal   7032343(%esi), %edx
0x14de769:  movl   %edx, 20(%esp)
0x14de76d:  movl   %eax, 12(%esp)
0x14de771:  movl   %edi, 8(%esp)
0x14de775:  movl   %ecx, 4(%esp)
0x14de779:  movl   -16(%ebp), %eax
0x14de77c:  movl   %eax, (%esp)
0x14de77f:  movl   $1732, 16(%esp)
0x14de787:  calll  0x0198790a               ; objc_msgSend
0x14de78c:  xorl   %edi, %edi
0x14de78e:  leal   1159(%esi), %eax
0x14de794:  movl   %eax, (%esp)
0x14de797:  calll  0x019870be               ; GSEventRegisterEventCallBack
0x14de79c:  movl   6928967(%esi), %eax
0x14de7a2:  movl   %eax, 4(%esp)
0x14de7a6:  movl   %edi, (%esp)
0x14de7a9:  calll  0x0198790a               ; objc_msgSend
0x14de7ae:  movl   6929831(%esi), %ecx
0x14de7b4:  movl   %ecx, 4(%esp)
0x14de7b8:  movl   %eax, (%esp)
0x14de7bb:  calll  0x0198790a               ; objc_msgSend
0x14de7c0:  testb  %al, %al
0x14de7c2:  setne  %al
0x14de7c5:  movzbl %al, %eax
0x14de7c8:  movl   %eax, (%esp)
0x14de7cb:  calll  0x01987070               ; GSEventInitialize
0x14de7d0:  movl   6432387(%esi), %eax
0x14de7d6:  movl   (%eax), %eax
0x14de7d8:  movl   %eax, (%esp)
0x14de7db:  calll  0x019870ac               ; GSEventPushRunLoopMode
0x14de7e0:  calll  0x019873b2               ; SBSSpringBoardServerPort
0x14de7e5:  movl   6432211(%esi), %ecx
0x14de7eb:  movl   (%ecx), %ecx
0x14de7ed:  movl   %ecx, 4(%esp)
0x14de7f1:  movl   %eax, (%esp)
0x14de7f4:  calll  0x0198731c               ; SBCheckInTaskPort
0x14de7f9:  movl   6930015(%esi), %eax
0x14de7ff:  movl   %eax, 4(%esp)
0x14de803:  movl   %edi, (%esp)
0x14de806:  calll  0x0198790a               ; objc_msgSend
0x14de80b:  movl   %edi, (%esp)
0x14de80e:  calll  0x014de40d               ; UIApplicationInstantiateSingleton
0x14de813:  movl   6976647(%esi), %eax
0x14de819:  movl   6928943(%esi), %ecx
0x14de81f:  movl   %ecx, 4(%esp)
0x14de823:  movl   %eax, (%esp)
0x14de826:  calll  0x0198790a               ; objc_msgSend
0x14de82b:  movl   6928975(%esi), %ecx
0x14de831:  movl   %esi, %edi
0x14de833:  movl   %ecx, 4(%esp)
0x14de837:  movl   %eax, (%esp)
0x14de83a:  calll  0x0198790a               ; objc_msgSend
0x14de83f:  testb  %al, %al
0x14de841:  je     0x014de85b               ; UIApplicationMain + 720
0x14de843:  movl   6976831(%edi), %eax
0x14de849:  movl   6930019(%edi), %ecx
0x14de84f:  movl   %ecx, 4(%esp)
0x14de853:  movl   %eax, (%esp)
0x14de856:  calll  0x0198790a               ; objc_msgSend
0x14de85b:  movl   20(%ebp), %ebx
0x14de85e:  testl  %ebx, %ebx
0x14de860:  jne    0x014de8b2               ; UIApplicationMain + 807
0x14de862:  movl   6976767(%edi), %eax
0x14de868:  movl   6929687(%edi), %ecx
0x14de86e:  movl   %ecx, 4(%esp)
0x14de872:  movl   %eax, (%esp)
0x14de875:  calll  0x0198790a               ; objc_msgSend
0x14de87a:  movl   6929695(%edi), %ecx
0x14de880:  movl   %ecx, 4(%esp)
0x14de884:  movl   %eax, (%esp)
0x14de887:  calll  0x0198790a               ; objc_msgSend
0x14de88c:  movl   6929699(%edi), %ecx
0x14de892:  leal   7032359(%edi), %edx
0x14de898:  movl   %edx, 8(%esp)
0x14de89c:  movl   %ecx, 4(%esp)
0x14de8a0:  movl   %eax, (%esp)
0x14de8a3:  calll  0x0198790a               ; objc_msgSend
0x14de8a8:  movl   %eax, %ebx
0x14de8aa:  testl  %ebx, %ebx
0x14de8ac:  je     0x014de9e9               ; UIApplicationMain + 1118
0x14de8b2:  movl   %ebx, (%esp)
0x14de8b5:  calll  0x01987214               ; NSClassFromString
0x14de8ba:  testl  %eax, %eax
0x14de8bc:  movl   %eax, -16(%ebp)
0x14de8bf:  jne    0x014de959               ; UIApplicationMain + 974
0x14de8c5:  movl   6976639(%edi), %eax
0x14de8cb:  movl   6928919(%edi), %ecx
0x14de8d1:  movl   %ecx, 4(%esp)
0x14de8d5:  movl   %eax, (%esp)
0x14de8d8:  calll  0x0198790a               ; objc_msgSend
0x14de8dd:  movl   %eax, -24(%ebp)
0x14de8e0:  movl   6976643(%edi), %eax
0x14de8e6:  movl   6928923(%edi), %ecx
0x14de8ec:  leal   5450237(%edi), %edx
0x14de8f2:  movl   %edx, 8(%esp)
0x14de8f6:  movl   %ecx, 4(%esp)
0x14de8fa:  movl   %eax, (%esp)
0x14de8fd:  calll  0x0198790a               ; objc_msgSend
0x14de902:  movl   %eax, %esi
0x14de904:  movl   6976643(%edi), %eax
0x14de90a:  movl   6928923(%edi), %ecx
0x14de910:  leal   5448982(%edi), %edx
0x14de916:  movl   %edx, 8(%esp)
0x14de91a:  movl   %ecx, 4(%esp)
0x14de91e:  movl   %eax, (%esp)
0x14de921:  calll  0x0198790a               ; objc_msgSend
0x14de926:  movl   6930011(%edi), %ecx
0x14de92c:  movl   %ebx, 24(%esp)
0x14de930:  leal   7032375(%edi), %edx
0x14de936:  movl   %edx, 20(%esp)
0x14de93a:  movl   %eax, 12(%esp)
0x14de93e:  movl   %esi, 8(%esp)
0x14de942:  movl   %ecx, 4(%esp)
0x14de946:  movl   -24(%ebp), %eax
0x14de949:  movl   %eax, (%esp)
0x14de94c:  movl   $1765, 16(%esp)
0x14de954:  calll  0x0198790a               ; objc_msgSend
0x14de959:  movl   6976747(%edi), %eax
0x14de95f:  movl   6928967(%edi), %ecx
0x14de965:  movl   %ecx, 4(%esp)
0x14de969:  movl   %eax, (%esp)
0x14de96c:  calll  0x0198790a               ; objc_msgSend
0x14de971:  movl   6930023(%edi), %ecx
0x14de977:  movl   %eax, 8(%esp)
0x14de97b:  movl   %ecx, 4(%esp)
0x14de97f:  movl   -16(%ebp), %esi
0x14de982:  movl   %esi, (%esp)
0x14de985:  calll  0x0198790a               ; objc_msgSend
0x14de98a:  movl   7181311(%edi), %ebx
0x14de990:  testb  %al, %al
0x14de992:  je     0x014de9a7               ; UIApplicationMain + 1052
0x14de994:  movl   6929035(%edi), %eax
0x14de99a:  movl   %ebx, 8(%esp)
0x14de99e:  movl   %eax, 4(%esp)
0x14de9a2:  movl   %ebx, (%esp)
0x14de9a5:  jmp    0x014de9e4               ; UIApplicationMain + 1113
0x14de9a7:  movl   6929119(%edi), %eax
0x14de9ad:  movl   %eax, 4(%esp)
0x14de9b1:  movl   %esi, (%esp)
0x14de9b4:  calll  0x0198790a               ; objc_msgSend
0x14de9b9:  movl   6929295(%edi), %ecx
0x14de9bf:  movl   %ecx, 4(%esp)
0x14de9c3:  movl   %eax, (%esp)
0x14de9c6:  calll  0x0198790a               ; objc_msgSend
0x14de9cb:  movl   6930027(%edi), %ecx
0x14de9d1:  movl   %eax, 8(%esp)
0x14de9d5:  movl   %ecx, 4(%esp)
0x14de9d9:  movl   %ebx, (%esp)
0x14de9dc:  movl   $1, 12(%esp)
0x14de9e4:  calll  0x0198790a               ; objc_msgSend
0x14de9e9:  movl   6928887(%edi), %eax
0x14de9ef:  movl   %eax, 4(%esp)
0x14de9f3:  movl   -20(%ebp), %eax
0x14de9f6:  movl   %eax, (%esp)
0x14de9f9:  calll  0x0198790a               ; objc_msgSend
0x14de9fe:  movl   7181311(%edi), %eax
0x14dea04:  movl   6930031(%edi), %ecx
0x14dea0a:  movl   %ecx, 4(%esp)
0x14dea0e:  movl   %eax, (%esp)
0x14dea11:  calll  0x0198790a               ; objc_msgSend
0x14dea16:  xorl   %eax, %eax            <<<<<<<<<<<<<<<<<<<<<<<<<< Signal SIGABRT
0x14dea18:  addl   $44, %esp
0x14dea1b:  popl   %esi
0x14dea1c:  popl   %edi
0x14dea1d:  popl   %ebx
0x14dea1e:  popl   %ebp
0x14dea1f:  ret    

Note: The error is thrown before load View of my ViewController.


回答1:


You may want to look into this question: objectForKeyedSubscript: crash on iOS 5.1

By the way, what's the version of Xcode you are using? What's the iOS SDK version you are using?


Developing an application with the Google Maps SDK for iOS requires the following:

  • Xcode 4.5 or later.
  • iOS SDK 6.0 or later.

Applications that use the Google Maps SDK for iOS will work on iOS 5.1 and above.

https://developers.google.com/maps/documentation/ios/intro




回答2:


Did you add the -ObjC flag in step 7 of the instructions?




回答3:


I had the same expection and it was solved by adding the -ObjC to other linker flags in build settings




回答4:


Other people have mentioned the following section from Google's Documentation

Choose your project, rather than a specific target, and open the Build Settings tab. In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.

However, it wasn't until I added the -ObjC flag into my projects 'Other Linker Flags' section, and NOT the targets 'Other Linker Flags' section, was I able to resolve the unrecognized selector error.



来源:https://stackoverflow.com/questions/15108418/ios-googlemaps-sdk-error-nscfdictionary-objectforkeyedsubscript-unrecogn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!