13

This is a single view application and I followed the instruction given at link https://developers.google.com/maps/documentation/ios/start for adding google map SDK to iOS6. ERROR Is:

unrecognized selector sent to class 0xe2b0
2013-02-07 15:21:29.788 mapApp[2061:12e03] *** Terminating app due to uncaught exception     
'NSInvalidArgumentException', reason: '+[GMSCameraPosition    
cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0xe2b0'

AppDelegate.m

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

   //initializing google map api key
   [GMSServices provideAPIKey:@"google's api key goes here"];

   [self.window makeKeyAndVisible];
   return YES;

}

ViewController.m

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

@end

@implementation ViewController
{
    GMSMapView *mapView;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

   GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231 
                                                        longitude:77.64072579999993                
                                                             zoom:6];

   mapView = [GMSMapView mapWithFrame:CGRectZero camera:cam];
   mapView.myLocationEnabled = YES;

   GMSMarkerOptions *options = [[GMSMarkerOptions alloc]init ];
   options.position = CLLocationCoordinate2DMake(13.025738,77.637809);
   options.title = @"ensign";
   options.snippet = @"kalyan nagar";

   [mapView addMarkerWithOptions:options];

}

main.m

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv,nil, NSStringFromClass([AppDelegate class]));
    }
}

While tracking the error it is showing at the return statement in main.m which comes from the method -viewDidLoad after executing the first line

GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231 
                                                    longitude:77.64072579999993                
                                                         zoom:6];

It escapes the rest of the lines.

Saxon Druce
  • 17,406
  • 5
  • 50
  • 71
mavericks
  • 1,589
  • 16
  • 24

3 Answers3

25

Did you add -ObjC to the Other Linker Flags, in step 7 of the instructions?

-- Extra information edit: note that -ObjC is case sensitive.

Steve Haley
  • 55,374
  • 17
  • 77
  • 85
Saxon Druce
  • 17,406
  • 5
  • 50
  • 71
  • Oops!.. thanks..I added now, Simulator Screen is blank and I am getting this message in Log Screen: 2013-02-08 10:28:17.061 mapApp[487:14603] Google Maps SDK for iOS version: 1.0.2.1667 2013-02-08 10:28:17.369 mapApp[487:12e03] ClientParametersRequest failed, 3 attempts remaining. Error Domain=DASHConnectionError Code=100 "The operation couldn’t be completed. (DASHConnectionError error 100.)"...And this same message is repeating 16 times. – mavericks Feb 08 '13 at 05:07
  • 1
    That seems to be the error that you get if you haven't provided the correct API key. Are you sure that you've used an API key for the iOS SDK? For example see here: http://stackoverflow.com/questions/14103518/how-can-i-integrate-google-map-in-my-iphone-app – Saxon Druce Feb 08 '13 at 05:09
  • Yes, I am sure of it. Because I also get through with similar kind of question.Thence I added newly created key, then also the Error is same.And this is the new key==>>@"AIzaSyA5RujfEHK5eSqCifcow-xnHOOtwH9_AFE" – mavericks Feb 08 '13 at 05:22
  • Maybe check that your app's bundle ID matches the bundle ID you entered into the APIs console? – Saxon Druce Feb 08 '13 at 05:42
  • I was able to get the same error by changing the bundle ID in the APIs console to something incorrect, and then it was fixed when I changed the bundle ID in the APIs console back again. Although both times it took 5 minutes or so for the behaviour to change (I guess after making the change in the APIs console, it takes a while to propagate around Google's systems). – Saxon Druce Feb 08 '13 at 05:54
  • I am seeing the exact same error, did you figure out what was wrong? – Dmorneault Feb 23 '13 at 05:48
  • @Dmorneault, make sure that your bundle ID matches, and also that you've enabled the Google Maps SDK for iOS service (step 2 under https://developers.google.com/maps/documentation/ios/start#obtaining_an_api_key ). – Saxon Druce Feb 23 '13 at 06:07
  • My bundle ID does match. The only thing I wasnt sure of is the architectures. Do I remove armv7s from Architectures or Valid Architectures? Would this cause this error? – Dmorneault Feb 24 '13 at 17:38
  • You need to change Architectures from the default of `$(ARCHS_STANDARD_32_BIT)` - which means `armv7 armv7s` - to just `armv7`. But no, if you don't do this, you get a different linker error during compiling, not this runtime error. – Saxon Druce Feb 25 '13 at 11:26
  • I have added all the frameworks, architecture is armv7 only, added the -ObjC linker flag, bundleID is correct, I enabled the SDK, provided the API key. What am I missing? – Norbert Bicsi Apr 19 '13 at 03:16
  • The thing is there is nothing wrong with your prog I guess..nor any thing missing in the information provided by google.I'd followed their instructions line by line for almost one month then also i was not getting anything on screen.But some fine day, somewhere in Feb, i got the mail, because I'd registered before, from google that they have released their api for iOS, that day i tried with the new key then it Worked. If you want you may send ur code to me at uk.abhishek@live.com. – mavericks Apr 23 '13 at 09:45
  • What worked for me is setting the -ObjC linker flag on both the project and the target. The target must have been overriding the flag. – Mark May 09 '13 at 17:14
8

I had the same problem. Make sure you add the -ObjC flag to the 'Build Settings' of your 'Target' and NOT 'Project'.

P.S. Adding it in both places doesn't break it either.

Norbert Bicsi
  • 1,562
  • 2
  • 19
  • 33
0

Google Doc says 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. Sometimes this is wrong.... I had to add the linker flag to the target as well, to get it to work. This should help someone