若是你在2019年8月以前將Flutter添加到現有iOS項目,本文值得你一看。ios
在2019年7月30日,合併合併請求flutter / flutter#36793以前Flutter 1.8.4-pre.21
,git
將Flutter添加到現有的iOS應用程序須要更改Podfile,github
並在現有Xcode項目中添加運行腳本構建階段。xcode
要在此拉取請求以後更新到Flutter,您必須更改Podfile,刪除「運行腳本」構建階段,而後從新生成podhelper腳本。app
之前,須要將如下幾行添加到Podfile
:ui
flutter_application_path = 'path/to/my_flutter/' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
這應該更新爲:spa
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
之前,須要將構建階段添加到現有Xcode項目中:code
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
此構建階段再也不是必需的,必須刪除。blog
cd 'path/to/my_flutter/' rm .ios/Flutter/podhelper.rb flutter build ios