rosnk
rosnk

Reputation: 1098

Google Map SDK integration with ios6

I created API key and tried in demo project provided by google and google map works fine. However trying to create a sample project and integrating google map sdk crashes in run time.

Steps Followed

Created a single view application with disabled USE STORYBOARDS and ARC on. Created a API key using bundle identifier of my project which is rosnMapTest Copied GoogleMapsframework bundle into Framework group. Copied GoogleMapsbundle from Resources folder into Framework group Added all of the following framework

<pre>
<code>
    AVFoundation.framework  
    CoreData.framework
    CoreLocation.framework 
    CoreText.framework 
    GLKit.framework 
    ImageIO.framework 
    libicucore.dylib  
    libstdc++.dylib  
    libz.dylib 
    OpenGLES.framework 
    QuartzCore.framework  
    SystemConfiguration.framework
</code>
</pre>

Fixed the default Architectures and Other Linker Flags

Imported GoogleMaps.h and added google API key in AppDelegate


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

Added following code in viewcontroller

<pre>
<code>
     #import "TestViewController.h"
        #import <GoogleMaps/GoogleMaps.h>
        @interface TestViewController ()

        @end

        @implementation TestViewController
        GMSMapView *mapView_;

        - (void) viewDidLoad
        {
            [super viewDidLoad];

        }

        - (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
</code>
</pre>

<pre>
<code>
Error in RUNTIME: “2013-02-23 19:37:27.697 MapTest[2947:c07] +[GMSCameraPosition cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0xf2a4
(lldb)”
</code>
</pre>

Upvotes: 1

Views: 1838

Answers (3)

y0gie007
y0gie007

Reputation: 727

You can use Storyboards. It makes iOS life easier i think :)

You have a working example here

There is also OpenGL controller attached onto Google maps controller. If you dont want it you can ignore it by removing the following code in ViewController.m:

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
    _openGLController = (OpenGLController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"openGLController"];

[self addChildViewController:_openGLController];
[self.view addSubview:_openGLController.view];
[self didMoveToParentViewController:self];

With this one i can help you out if you run into problems.

Upvotes: 1

Norbert Bicsi
Norbert Bicsi

Reputation: 1568

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.

Upvotes: 0

Long Pham
Long Pham

Reputation: 7582

I think. You not setting at step 7

https://developers.google.com/maps/documentation/ios/start#add_a_map

"Choose your project, rather than a specific target, and open the Build Settings tab. Replace the default value of Architectures with armv7. 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."

Upvotes: 2

Related Questions