注:百度地图iOS SDK向广大开发者提供了配置更简单的 .framework形式的开发包。自v2.9.0起,百度地图iOS SDK将不再提供 .a形式的开发包。
.framework的怎么用,官网上看不懂。
http://lbsyun.baidu.com/index.php?title=iossdk/theupdatelog
PHPz2017-04-17 18:01:58
Following the official operation, it has not been successful. The following is my successful experience a month ago, please refer to:
Assume that you already have a development account and the application application has been approved.
1. Customize and download the basic package sdk of baidu map. After unzipping, copy BaiduMapAPI_*.framework to the root directory of the project folder.
2. Project properties, Build Phases >
Link binary with libraries, add:
BaiduMapAPI_Base.framework;
BaiduMapAPI_Map.framework;
CoreGraphics.framework;
CoreLocation.framework;
CoreTelephony.framework;
Security.framework;
SystemConfiguration.framework;
OpenGLES.framework;
QuartzCore.framework;
libsqlite3.0.tbd;
libstdc++.6.0.9.tbd;
3. Project properties, Build Settings >
3.1 This step does not follow Baidu official documentation, keep "According to File Type" unchanged
3.2 Linking > Other Linker Flags, add -ObjC
4. Right-click menu "add files to", add mapapi.bundle file to the project:
BaiduMapAPI_Map.framework/Resources/mapapi.bundle
5. Modify Info.plist and add:
5.1 https access
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
5.2 bundle identifier:
<key>CFBundleDisplayName</key>
<string>HelloBaiduMap</string>
6.Code:
//
// AppDelegate.h
// HelloBaiduMap
//
// Created by Jeffrey Zhang on 16/3/25.
// Copyright © 2016年 Jeffrey Zhang. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相关所有的头文件
#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
//#import <BaiduMapAPI_Map/BMKMapView.h>//只引入所需的单个头文件
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) BMKMapManager *mapManager;
@end
//
// AppDelegate.m
// HelloBaiduMap
//
// Created by Jeffrey Zhang on 16/3/25.
// Copyright © 2016年 Jeffrey Zhang. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
_mapManager = [[BMKMapManager alloc]init];
// 如果要关注网络及授权验证事件,请设定 在此处输入您的授权Key , generalDelegate参数
BOOL ret = [_mapManager start:@"8CxxxxxxxxxxxxxxxxxxxxL" generalDelegate:nil];
if (!ret) {
NSLog(@"manager start failed!");
}
return YES;
}
//
// ViewController.m
// HelloBaiduMap
//
// Created by Jeffrey Zhang on 16/3/25.
// Copyright © 2016年 Jeffrey Zhang. All rights reserved.
//
#import "ViewController.h"
#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相关所有的头文件
#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
@interface ViewController ()
@end
@implementation ViewController
-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
BMKMapView *mapView = [[BMKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
self.view = mapView;
}
[FAQ]
manager start failed: Bundle display name must be added to info.plist