首页 > 百度地图SDK:.framework形式的开发包

百度地图SDK:.framework形式的开发包

注:百度地图iOS SDK向广大开发者提供了配置更简单的 .framework形式的开发包。自v2.9.0起,百度地图iOS SDK将不再提供 .a形式的开发包。

.framework的怎么用,官网上看不懂。
http://lbsyun.baidu.com/index.php?title=iossdk/theupdatelog


按照官方操作,没有成功过,下面是我一个月前的成功经验,请参考:
假设你已经有了开发账号,应用申请也审核通过。
1.定制下载baidu地图的基础包sdk,解压后,拷贝 BaiduMapAPI_*.framework 到项目文件夹根目录。
2.项目属性,Build Phases >
Link binary with libraries, 加入:

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.项目属性,Build Settings >
3.1 这一步没有按baidu官方文档做,保持”According to File Type"不变
3.2 Linking > Other Linker Flags,加入 -ObjC

4.右键菜单”add files to”, 添加mapapi.bundle文件到项目:
BaiduMapAPI_Map.framework/Resources/mapapi.bundle

5.修改Info.plist, 加入:
5.1 https的访问

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

5.2 bundle identifier:

<key>CFBundleDisplayName</key>
<string>HelloBaiduMap</string>

6.代码:

//
//  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;
}

[常见问题]
manager start failed : info.plist 中必须添加 Bundle display name

【热门文章】
【热门文章】