Cocoa Pods and Google Maps SDK

泄露秘密 提交于 2019-12-08 02:15:30

问题


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?


回答1:


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




回答2:


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).



来源:https://stackoverflow.com/questions/17452338/cocoa-pods-and-google-maps-sdk

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