grandouassou
grandouassou

Reputation: 2530

Cocoa Pods and Google Maps SDK

When using CocoaPods to get the Google Maps SDK for iOS, I'm having troubles importing the sdk header file (#import <GoogleMaps/GoogleMaps.h>).
I'm new to CocoaPods but I think I have everything working fine with the other libraries that I use (RestKit, AFNetworking...). For these APIs I still need to import the lib like this #import <AFNetworking/AFNetworking.h> instead of just #import "AFNetworking". But it works fine.
For Google Maps SDK I need to import it like this #import <Google-Maps-iOS-SDK/GoogleMaps/GoogleMaps.h> which leads to a compilation error because in the GoogleMaps.h header the other files are imported like this:

#import <GoogleMaps/GMSCameraPosition.h>
#import <GoogleMaps/GMSCameraUpdate.h>
#import <GoogleMaps/GMSCircle.h>
...

Did I miss something?

Upvotes: 2

Views: 2473

Answers (2)

SpikeyCoder
SpikeyCoder

Reputation: 1

I ran into the same issue(and am using cocoapods), specifically where the error "GoogleMaps.h" file not found. My solution(if the above fails to work), is that your Pods' Target Support Files fail to include the correct header path for "GoogleMaps.h".

Step #1

If you examine your project directory in Finder, click on Pods directory, then Public directory, then GoogleMaps directory, you'll notice that there is a second GoogleMaps directory. Inside that second GoogleMaps directory contains the header files pertaining to the GoogleMaps pod. Now time to check that Pods target support files have this path as the header path for GoogleMaps.

Step #2

Close Xcode Project. Go to the parent directory of your project. For me, it's my home directory, which can be reached at cd ~. Traverse into your Pods' Target support files:

cd ~/{your_project_name}/Pods/Target Support Files/Pods

Then open up your Pods.debug.xcconfig file in your favorite editor:

vi Pods.debug.xcconfig

Edit the line

HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/GoogleMaps"

with the new header path

HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/GoogleMaps/GoogleMaps"

Leave the rest of the Pods.debug.xcconfig untouched. Follow this same process for Pods.release.xcconfig.

Step #3

Re-open your .xcworkspace file. Clean your project(cmd-shift-k) and then re-build(cmd-b).

Upvotes: 0

Keith Smiley
Keith Smiley

Reputation: 63914

You should not have to import anything linked with CocoaPods using < and >. It should simply be #import "Foo.h". In the case of Google Maps based on my test project I just had to use #import "GoogleMaps.h" and it imported correctly. Make sure you're installing with the newest version of CocoaPods (pod --version currently 0.21.0) otherwise you may need to update it ([sudo] gem update). Also make sure you're opening the created xcworkspace file instead of the xcodeproject

Upvotes: 5

Related Questions