部署目标版本:iOS 7.0
我已经添加了这个pod:pod 'Google-Maps-iOS-SDK'
,'~> 1.8',并成功下载和安装了sdk。
我开始从此处添加头文件和示例地图视图加载代码。
我已经正确添加了API密钥。在一个视图控制器的- (void)viewDidLoad
中,我添加了以下代码:
// 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_;
我在为iPhone(不是模拟器)构建时遇到了以下错误:
针对armv7架构未定义符号:
"_OBJC_CLASS_$_GMSMarker",来自: 在DealDetailsViewController.o中引用的objc-class-ref "_OBJC_CLASS_$_GMSMapView",来自: 在DealDetailsViewController.o中引用的objc-class-ref "_OBJC_CLASS_$_GMSCameraPosition",来自: 在DealDetailsViewController.o中引用的objc-class-ref "_OBJC_CLASS_$_GMSServices",来自: 在AppDelegate.o中引用的objc-class-ref ld:符号(s)未找到,适用于architecture armv7 clang:链接器命令失败,退出代码为 1(使用-v查看调用)
我还尝试过使用google地图iOS SDK手动安装(而不是使用cocoapods)。我还添加了链接器标志:-ObjC
。它能够成功构建,但在运行时崩溃,显示如下的选择器未找到错误:
抛出了一个NSException异常,其中包含描述- [GMSMapView animateToCameraPosition:]:向实例发送未识别的选择器。
我只需要使用Google地图iOS SDK,无论是使用cocoapod还是手动安装。
我是否漏掉了什么?
编辑
如果涉及到Pods.xcconfig,那么这个文件的内容如下: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
xcrun -sdk iphoneos lipo -info XXX.a
。 - Rivera