Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

objective c - Apple Mach-O Linker Error when using Google Maps SDK for IOS

I am trying to use the Google Maps SDK in my app. So far, I have linked all the frameworks. I am pretty sure I have added the appropriate -ObjC flags as per the instructions. However, when I copied and pasted their code into my ViewController.m class, I get the following errors:

Undefined symbols for architecture i386:
"_OBJC_CLASS_$_GMSCameraPosition", referenced from: objc-class-ref in FoothillTourViewController.o "_OBJC_CLASS_$_GMSMapView", referenced from: objc-class-ref in FoothillTourViewController.o "_OBJC_CLASS_$_GMSMarker", referenced from: objc-class-ref in FoothillTourViewController.o "_OBJC_CLASS_$_GMSServices", referenced from: objc-class-ref in FoothillTourAppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

"FoothillTourViewController" is the name of my ViewController class. Here is the code for my View Controller class. The code is taken straight from the instructions.

#import "FoothillTourViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@implementation FoothillTourViewController {
    GMSMapView *mapView_;
}

// You don't need to modify the default initWithNibName:bundle: method.

  - (void)loadView {
  //Create a GMSCameraPosition that tells the map to display the
  // coordinate -33.86,151.20 at zoom level 6.
  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_;
  }

Any help would be greatly appreciated as I have been spending hours trying to figure out what is happening. I'm guessing its a stupid mistake, but I can't put my finger on it. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

UPDATE: this answer is outdated. The documentation now tells you to use CocoaPods instead of manually linking dependencies.

For more information, see Google Developers Console.

OLD ANSWER:

The Google Maps SDK requires you to link quite a few frameworks. Here they are:

  • AVFoundation.framework
  • CoreData.framework
  • CoreLocation.framework
  • CoreText.framework
  • GLKit.framework
  • ImageIO.framework
  • libc++.dylib
  • libicucore.dylib
  • libz.dylib
  • OpenGLES.framework
  • QuartzCore.framework
  • SystemConfiguration.framework

I found this list at here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...