首先 讓我們的iOS項(xiàng)目 關(guān)聯(lián) Flutter模塊,使用cocoapods關(guān)聯(lián),在podfile文件里添加如下代碼:
flutter_application_path = '../flutter_module' //flutter模塊的路徑
load File.join(flutter_application_path,'.iOS','Flutter','podhelper.rb') //函數(shù)調(diào)用加載flutter
platform :ios, '12.0'
target 'NativeDemo' do
install_all_flutter_pods(flutter_application_path)
use_frameworks!
# Pods for NativeDemo
end
然后pod install 第一次報(bào)錯(cuò):
[!] Invalid `Podfile` file: Missing `flutter_post_install(installer)` in Podfile `post_install` block.
# from /Users/zhangfan/Desktop/flutter_folder/NativeDemo/Podfile:7
# -------------------------------------------
# target 'NativeDemo' do
> install_all_flutter_pods(flutter_application_path)
# use_frameworks!
# -------------------------------------------
處理方法:
在podfile結(jié)尾添加
target 'app' do
// 用的各sdk
end
// 新增的配置
post_install do |installer|
flutter_post_install(installer) if defined?(flutter_post_install)
end
繼續(xù)pod install 第二次報(bào)錯(cuò):
[!] CocoaPods could not find compatible versions for pod "Flutter":
In Podfile:
Flutter (from `../flutter_module/.ios/Flutter`)
Specs satisfying the `Flutter (from `../flutter_module/.ios/Flutter`)` dependency were found, but they required a higher minimum deployment target.
處理方法:
修改原生Podfile文件里的Platform的版本號(hào) 和 flutter中iOS下Flutter.podspec文件中的ios.deployment_target 版本號(hào)一致!
flutter_application_path = '../flutter_module'
load File.join(flutter_application_path,'.iOS','Flutter','podhelper.rb')
platform :ios, '12.0'//這里的版本號(hào)!和下圖中ios.deployment_target 版本號(hào)一致!
target 'NativeDemo' do
install_all_flutter_pods(flutter_application_path)
use_frameworks!
# Pods for NativeDemo
end
post_install do |installer|
flutter_post_install(installer) if defined?(flutter_post_install)
end

圖片.jpg
pod install 成功后,編譯項(xiàng)目第三次報(bào)錯(cuò) :
Sandbox: rsync.samba(30002) deny(1) file-write-create /Users/zhangfan/Library/Developer/Xcode/DerivedData/NativeDemo-csscysefpzumudflovqmzgvixwno/Build/Products/Debug-iphonesimulator/Flutter.framework

編譯報(bào)錯(cuò).jpg
處理方法:
1.Xcode targets 里面 buildsettings 搜索 User Script Sanboxing 改為 NO

user script.jpg
-
新版本的Xcode 15 編譯報(bào)該錯(cuò)誤 右側(cè)[工具欄]項(xiàng)目的workspace 和 pod的 space 都選擇為15.0 即可.
修改Xcode版本.jpg
最后編譯成功!!
