使用某个三方库时,跑在IOS上报错。html
最近在作蓝牙相关的,须要用到蓝牙库,就找到了flutter_reactive_ble这个库。最后运行在ios上时,直接报错。react
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `device_info_plus` from `.symlinks/plugins/device_info_plus/ios`
-> Fetching podspec for `flutter_reactive_ble` from `.symlinks/plugins/flutter_reactive_ble/ios`
-> Fetching podspec for `location_permissions` from `.symlinks/plugins/location_permissions/ios`
-> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
Resolving dependencies of `Podfile`
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
[!] CocoaPods could not find compatible versions for pod "flutter_reactive_ble":
In Podfile:
flutter_reactive_ble (from `.symlinks/plugins/flutter_reactive_ble/ios`)
Specs satisfying the `flutter_reactive_ble (from `.symlinks/plugins/flutter_reactive_ble/ios`)` dependency were found, but they required a higher minimum deployment target.
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:328:in `raise_error_unless_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:310:in `block in unwind_for_conflict'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `tap'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:308:in `unwind_for_conflict'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
Error output from CocoaPods:
↳
[!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error running pod install
Error launching application on iPhone 12 Pro Max.
复制代码
打开ios项目中的pods/Local Podspecs目录,这里面存储的是全部pubspec.yaml中使用的了的三方库配置信息,由于我这个项目是由于flutter_reactive_ble这个库而引发的问题,因此打开flutter_reactive_ble.podspec.json,在最下面能够看到如下内容ios
"platforms": {
"ios": "11.0",
"osx": "10.13"
},
复制代码
看到这里就能知道什么问题啦了。json
这个库要求ios的最低版本在11.0。而个人项目尚未指定最低版本,默认就使用了9.0来编译。因此会提示不兼容。xcode
打开ios/Podfile文件,将第二行的内容去掉注释。将后面的版本改成上面库里面对应的版本便可。markdown
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '11.0'
复制代码
由于flutter_reactive_ble最低要求11.0,因此在这里改为11.0便可。最后从新运行,等待pod install、xcode build以后,就能成功运行起来了。app