前提:Flutter 項(xiàng)目中引入使用多個(gè)插件,內(nèi)含有swift與靜態(tài)庫時(shí)出現(xiàn)的一系列問題
問題一鬓催、swift插件缺少設(shè)置swift的版本號(hào)
Launching lib/main.dart on iPhone XS Max in debug mode...
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 `.symlinks/flutter/ios`
-> Fetching podspec for `swift_plugin` from `.symlinks/plugins/swift_plugin/ios`
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
A Flutter
A swift_plugin
Downloading dependencies
-> Installing Flutter (1.0.0)
-> Installing swift_plugin (0.0.1)
- Running pre install hooks
[!] Unable to determine Swift version for the following pods:
- `swift_plugin` does not specify a Swift version and none of the targets (`Runner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:115:in `verify_swift_pods_swift_version'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer/xcode/target_validator.rb:37:in `validate!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:459:in `validate_targets'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/installer.rb:138:in `install!'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command/install.rb:48:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:22:in `load'
/usr/local/bin/pod:22:in `<main>'
解決方案:在Xcode中打開項(xiàng)目Targets—>builds settings —>user-defined
在user-defined內(nèi)添加一行:SWIFT_VERSION(版本號(hào)視當(dāng)前版本號(hào)為準(zhǔn))
image.png
問題二、靜態(tài)庫
看到網(wǎng)上好多的解決方法是刪除掉或者添加上Podfile中的use_frameworks!,實(shí)測(cè)與此無關(guān),錯(cuò)誤信息忘記截圖啦??蹲嚣,大體就是pod install 時(shí)出現(xiàn)無法install之類的信息
正解方法是找到相關(guān)錯(cuò)誤插件內(nèi)的podspec文件徘意,添加s.static_framework = true
image.png