環(huán)境: macOS10.15.1 CocoaPods1.84 Xcode11.2.1 Flutter 1.9.1+hotfix.6
該演示需要flutter項目和iOS項目位于同一級目錄捅暴,如下FlutterModuleIntoiOS
和flutter_module_smples
位于同一級目錄下
├── FlutterModuleIntoiOS
│ ├── FlutterModuleIntoiOS
│ ├── FlutterModuleIntoiOS.xcodeproj
│ ├── FlutterModuleIntoiOS.xcworkspace
└── flutter_module_smples
├── README.md
├── build
├── flutter_module_smples.iml
├── flutter_module_smples_android.iml
├── lib
├── pubspec.lock
├── pubspec.yaml
└── test
通過CocoaPods嵌入Flutter SDK
- 在需要的引入的iOS代碼創(chuàng)建一個
Podfile
文件(已創(chuàng)建直接看第二步)
pod init
- 在Podefile添加以下內(nèi)容
platform :ios, '9.0'
flutter_application_path = '../flutter_module_smples'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'FlutterModuleIntoiOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
install_all_flutter_pods(flutter_application_path)
end
-
flutter_module_smples
這個是flutter項目的所在的文件名 -
FlutterModuleIntoiOS
iOS項目的Traget name
- 安裝flutter moudle
pod install
image.png
如果出現(xiàn)這樣港令,引入flutter成功
可能遇到的問題
Command PhaseScriptExecution failed with a nonzero exit code
腳本報錯.png