iOS原生項(xiàng)目嵌入Flutter,pod install報(bào)錯(cuò)問(wèn)題

首先 讓我們的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
  1. 新版本的Xcode 15 編譯報(bào)該錯(cuò)誤 右側(cè)[工具欄]項(xiàng)目的workspace 和 pod的 space 都選擇為15.0 即可.


    修改Xcode版本.jpg

最后編譯成功!!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容