Recent projects to use the Map function, first do a survey. Baidu's iOS development environment needs to have two points, a key two SDK. On Baidu Search "iOS Baidu Map API", and then open the page "Baidu Map api-Home". All required conditions can be obtained on this website.
One get secret key
Click on "Request Key" on the official website
Click Create App
Here are a few things to note:
1 Application Type Select the IOS sdk;2 security code is the bundle ID of the app using the Baidu maps SDK.
Click Submit, so you can see the secret key that Baidu assigned to you in the list of apps under your account. The Access Application (AK) field is the secret key.
Two get the SDK and configure the environment
In the iOS Map SDK > related downloads, select Traditional. A form static library (this article takes. A as an example and wants to use the. Framework of Friends Please self-study and thanks for sharing ^_^), download all. Decompression, in the Baidumap_iossdk_v2.8.0_lib directory can be seen Baidu gave two. a files, respectively, the real machine and the simulator. Open the terminal and execute the command to package two. A files into a. A file that can be used either as a real machine or as a simulator.
Then drag the resulting. A file into the project. Drag the header files from all SDKs in the INC directory to the project. Drag the Mapapi.bundle into the project.
Add Framework:Foundation.framework, Uikit.framework, Messageui.framework, Security.framework, Coregraphics.framework, Systemconfiguration.framework, Opengles.framework, Quartzcore.framework, Corelocation.framework.
Change the appdelegate.m file suffix to. mm (because the SDK implementation is written in C + +, you need at least one C + + file in the project.) Also do not rename, set the compile source as in the project to Objective C + +).
Modify the Bundleid and display name of the project according to the information entered in the secret key.
Add fields Nslocationalwaysusagedescription and nslocationwheninuseusagedescription in Info.plist with a value of Yes (the app starts with the user asking for permission and two fields are set when the latter takes effect) 。 Add the bundle Display Name field, otherwise Baidu map initialization will be error.
Add in AppDelegate.h bmkgeneraldelegate Protocol (check network status)
Add code to APPDELEGATE.MM
Add code to Viewcontroller
Compile, run.
Problem solving:
1 compile prompt does not support arm64, armv7 and so on, first please confirm that the project is set to Objectiv C + + compilation mode, and second please confirm that all the frameworks have been added.
2 No authorization is successful, please confirm the key application process, Bundleid, etc. are filled in correctly.
3 No Entry Didupdatebmkuserlocation The callback function, set the The _locservice variable is set to the member variable, the local variable given in the Baidu example disappears, and the service that starts is stopped naturally.
So far, the installation of the environment is ready and will continue to share specific usage notes later.
iOS Baidu Map notes (Environment installation)