iOS項目中集成Flutter的最新適配升級


 

如果你在2019年8月之前將Flutter添加到現有iOS項目,本文值得你一看。

2019年7月30日,合並合並請求flutter / flutter#36793之前Flutter 1.8.4-pre.21

將Flutter添加到現有的iOS應用程序需要更改Podfile,

並在現有Xcode項目中添加運行腳本構建階段。

要在此拉取請求之后更新到Flutter,您必須更改Podfile,刪除“運行腳本”構建階段,然后重新生成podhelper腳本。

Podfile的改變

以前,需要將以下幾行添加到Podfile

flutter_application_path = 'path/to/my_flutter/'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)

 

 

這應該更新為:

flutter_application_path = 'path/to/my_flutter/'
  load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

  target 'MyApp' do
    install_all_flutter_pods(flutter_application_path)
  end
  target 'MyAppTests' do
    install_all_flutter_pods(flutter_application_path)
  end

 

構建階段,用於構建Dart代碼

以前,需要將構建階段添加到現有Xcode項目中:

"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed

此構建階段不再是必需的,必須刪除。

 

重新生成podhelper.rb

cd 'path/to/my_flutter/'
rm .ios/Flutter/podhelper.rb
flutter build ios

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM