George Young
George Young

Reputation: 29

Google places with objective c errors

Hello I just used pods to implement google places with my application but when I try to run my app I get this error.

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

this is my pod file:

source 'https://github.com/CocoaPods/Specs.git'
project '/Users/GeorgeYoung/Desktop/Travel/Travel.xcodeproj'
target 'Travel' do
pod 'GooglePlaces'
end

The error apears to be coming from the AppDelegate.m

[GMSPlacesClient provideAPIKey:@"AIzaSyBYRDTp7U-633XB81qsBeOiVGhokPrc6_M"];

Podfile.lock:

PODS:
  - GoogleMaps/Base (2.4.0)
  - GooglePlaces (2.4.0):
    - GoogleMaps/Base (= 2.4.0)

DEPENDENCIES:
  - GooglePlaces

SPEC CHECKSUMS:
  GoogleMaps: 8436ab5d1c25e36915b2f7416d0c8e3fa2e76c61
  GooglePlaces: aafe5990fa7951e98e078761bbdaaf236d7e0c65

PODFILE CHECKSUM: e564be8d79cfc6ae7b4a4a197ee6149eac7d65d2

COCOAPODS: 1.3.1

Upvotes: 0

Views: 518

Answers (3)

Juan Carlos
Juan Carlos

Reputation: 43

Modify your pod file:

pod 'GooglePlaces'

pod 'GooglePlacePicker'

pod 'GoogleMaps'

Upvotes: 0

idz
idz

Reputation: 12988

If source code for the library is available, CocoaPods is pretty good about making sure the correct architecture is built. In this case, the Google Places library is a pre-build library so there is a risk that it did not contain a slice with correct architecture. The file command can be used to check if a library contains a slice. The next possibility is that somehow the library was not included in the link. This can happen if you open the Xcode project instead of the Xcode workspace created by CocoaPods. Checking that the workspace is indeed being used and that Pod library is being linked can be used to eliminate this problem. Finally, if all else fails (and again CocoaPods usually seems to get this correct) make sure the 'Other Linker Flags' build setting contains the -ObjC setting. This is need to force the loading on some Objective-C symbols from static libraries.

So in summary

  1. Check prebuilt libraries contain the needed slice
  2. Make sure you're using the workspace not the project
  3. Make sure the Pod library is included in the link
  4. Make sure -ObjC is specified in the 'Other Linker Flags'

Upvotes: 2

bbum
bbum

Reputation: 162712

You're either not linking against the library that contains GMSPlacesClient or you built the library with the wrong architecture.

Upvotes: 0

Related Questions