Undefined symbols for architecture armv7 while using Google-Maps-iOS-SDK (1.8.1)

梦想与她 提交于 2019-11-29 14:39:45

问题


I am trying to add Google-Maps-iOS-SDK (1.8.1) using cocoapods (0.33.1).

Deployment target version: iOS 7.0

I have added this pod: pod 'Google-Maps-iOS-SDK', '~> 1.8' Downloaded and installed sdk properly.

I started adding header file and sample map view loading code from here.

I have properly added API keys. In one view controller's - (void)viewDidLoad,
I have added following code:

 // 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];
GMSMapView *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_; 

I got this error on build for iPhone (not in simulator)

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

I also tried using google map iOS sdk manual installation (without cocoapods). I have also added linker flag: -ObjC. It builds fine but crash on runtime showing selector not found error like this:

an NSException is thrown with the description - -[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance.

I just need to use google map iOS SDK either using cocoapod or from manual installation.

Am I missing anything here?

Edit

If there is anything related with Pods.xcconfig then here is the content of that file:

FRAMEWORK_SEARCH_PATHS = "$(PODS_ROOT)/Google-Maps-iOS-SDK" "$(PODS_ROOT)/Parse-iOS-SDK"
    GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
    HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/Bolts" "${PODS_ROOT}/Headers/Facebook-iOS-SDK" "${PODS_ROOT}/Headers/Facebook-iOS-SDK/FacebookSDK" "${PODS_ROOT}/Headers/Google-Maps-iOS-SDK" "${PODS_ROOT}/Headers/Google-Maps-iOS-SDK/GoogleMaps" "${PODS_ROOT}/Headers/MBProgressHUD" "${PODS_ROOT}/Headers/Parse-iOS-SDK" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/WYPopoverController"

    OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers" -isystem "${PODS_ROOT}/Headers/Bolts" -isystem "${PODS_ROOT}/Headers/Facebook-iOS-SDK" -isystem "${PODS_ROOT}/Headers/Facebook-iOS-SDK/FacebookSDK" -isystem "${PODS_ROOT}/Headers/Google-

    Maps-iOS-SDK" -isystem "${PODS_ROOT}/Headers/Google-Maps-iOS-SDK/GoogleMaps" -isystem "${PODS_ROOT}/Headers/MBProgressHUD" -isystem "${PODS_ROOT}/Headers/Parse-iOS-SDK" -isystem "${PODS_ROOT}/Headers/Reachability" -isystem "${PODS_ROOT}/Headers/WYPopoverController"

    OTHER_LDFLAGS = -ObjC -lc++ -licucore -lsqlite3 -lz -framework AVFoundation -framework AudioToolbox -framework CFNetwork -framework CoreData -framework CoreGraphics -framework CoreLocation -framework CoreText -framework GLKit -framework GoogleMaps -framework ImageIO -framework MobileCoreServices -framework OpenGLES -framework Parse -framework QuartzCore -framework Security -framework StoreKit -framework SystemConfiguration -framework UIKit -weak_framework Accounts -weak_framework AdSupport -weak_framework Security -weak_framework Social
    PODS_ROOT = ${SRCROOT}/Pods

回答1:


It's looks like the linker cannot find a sdk lib. Headers are present, but sdk objects-file not linked to a project.

Checking this:

BuildSettings->Linking->Other Linker Flags must have a value $(inherited)




回答2:


Did you follow all the steps mentioned below ?

  1. Launch Xcode and either open an existing project, or create a new project. If you're new to iOS, create a Single View Application, and disable Use Storyboards but ensure that Use Automatic Reference Counting is on.
  2. Drag the GoogleMaps.framework bundle to the Frameworks group of your project. When prompted, select Copy items into destination group's folder.
  3. Right-click GoogleMaps.framework in your project, and select Show In Finder.
  4. Drag the GoogleMaps.bundle from the Resources folder to your project. We suggest putting it in the Frameworks group. When prompted, ensure Copy items into destination group's folder is not selected.
  5. Select your project from the Project Navigator, and choose your application's target. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks: AVFoundation.framework
    CoreData.framework
    CoreLocation.framework
    CoreText.framework
    GLKit.framework
    ImageIO.framework
    libc++.dylib
    libicucore.dylib
    libz.dylib
    OpenGLES.framework
    QuartzCore.framework
    SystemConfiguration.framework

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. Finally, add your API key to your AppDelegate.

#import <GoogleMaps/GoogleMaps.h>

Add the following to your application:didFinishLaunchingWithOptions: method, replacing API_KEY with your API key.

[GMSServices provideAPIKey:@"API_KEY"];

Source: Google




回答3:


I often get the same error with other libs. I can't say the exact reason, but it happens when I switch between branches.

The workaround is plain:

  • remove workspace generated by cocoapods
  • clean project derived data Organiser -> Projects

  • run pod install

It always works for me.




回答4:


try to play around in pod file's platform setting Vs deployment target in your Target:

platform :ios, '7.0'

then run pod update in terminal.



来源:https://stackoverflow.com/questions/25248359/undefined-symbols-for-architecture-armv7-while-using-google-maps-ios-sdk-1-8-1

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