一、定位Flutter插件集成
pub依赖添加:
在工程pubspec.yaml文件添加如下代码:
dependencies:
flutter_bmflocation: ^1.0.2
- 执行
flutter pub get
flutter run
二、常见报错1
- 错误信息:
[!] No podspec found for 'flutter_bmflocation' in '.symlinks/plugins/flutter_bmflocation/ios'
意思是在flutter_bmfloaction/ios的目录下找不到flutter_bmflocation.podspec的文件 - 解决方式
1.打开.symlinks/plugins/flutter_bmflocation/ios路径
2.将bdmap_location_flutter_plugin.podspec
修改名字为flutter_bmflocation.podspec
3.打开flutter_bmflocation.podspec文件,在文件中将第6行修改为以下内容:
s.name = 'flutter_bmflocation'
三、常见报错2
- 错误信息:
... flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_bmflocation-1.0.2/ios/Classes/BdmapLocationFlutterPlugin.m:3:9: fatal error: 'BMKLocationkit/BMKLocationComponent.h' file not found ...
- 解决方式
1.打开路径flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_bmflocation-1.0.2/ios/Classes/BdmapLocationFlutterPlugin.m
2.打开BdmapLocationFlutterPlugin.m这个文件,将第三行改为:
#import "BMKLocationComponent.h"
3.然后会报找不到BMKLocationComponent 这个文件,这里需要手动部署百度iOS定位SDK,具体步骤可参照iOS定位SDK手动部署说明。
也可以自动部署http://lbsyun.baidu.com/index.php?title=ios-locsdk/guide/create-project/cocoapods-create:
1.打开ios/Podfile文件,添加
target 'Runner' do
pod 'BMKLocationKit'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
2.执行pod install