搜尋

首頁  >  問答  >  主體

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

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

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

高洛峰高洛峰2887 天前414

全部回覆(1)我來回復

  • PHPz

    PHPz2017-04-17 18:01:58

    按照官方操作,沒有成功過,以下是我一個月前的成功經驗,請參考:
    假設你已經有了開發帳號,應用申請也審核通過。
    1.自訂下載baidu地圖的基礎套件sdk,解壓縮後,拷貝 BaiduMapAPI_*.framework 到專案資料夾根目錄。
    2.項目屬性,Build Phases >
    Link binary with libraries, 加入:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    <code>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;

    </code>

    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的訪問

    1

    2

    3

    4

    5

    6

    <code>    <key>NSAppTransportSecurity</key>

        <dict>

            <key>NSAllowsArbitraryLoads</key>

            <true/>

        </dict>

    </code>

    5.2 bundle identifier:

    1

    2

    3

    <code><key>CFBundleDisplayName</key>

    <string>HelloBaiduMap</string>

    </code>

    6.代碼:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    38

    39

    40

    41

    42

    43

    44

    45

    46

    47

    48

    49

    50

    51

    52

    53

    54

    55

    56

    57

    58

    59

    60

    61

    62

    63

    64

    65

    66

    67

    68

    69

    70

    71

    72

    73

    74

    75

    76

    77

    78

    79

    80

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

    }

    </code>

    [常見問題]
    manager start failed : info.plist 中必須加入 Bundle display name

    回覆
    0
  • 取消回覆