為您解碼網(wǎng)站建設(shè)的點(diǎn)點(diǎn)滴滴
發(fā)表日期:2018-12 文章編輯:小燈 瀏覽次數(shù):2691
官方參考文檔
如果AppDelegate已從其他地方繼承,可參考
my_flutter, 命令行:flutter create -t module my_flutter Podfile中添加代碼:# 將flutter_application_path修改成my_flutter所在的路徑,可使用相對(duì)路徑,也可使用絕對(duì)路徑 use_frameworks!#根據(jù)是否引入了swifit來判斷是否添加該句代碼,作用是使swift可使用oc庫, 但是沒用swift的話,這句話不能用 flutter_application_path = 'path/to/my_flutter/' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding) 如果能如此簡(jiǎn)單就好了,但是一般不會(huì)這么容易。如果你對(duì)Podfile中已經(jīng)使用了post_install,那么你需要更麻煩的操作。因?yàn)?code>Podfile只能存在一個(gè)post_install,然后podhelper.rb中就有一個(gè)。具體怎么做請(qǐng)查看另一篇文章flutter 單一post_install的配置
pod install。無論什么時(shí)候修改了my_flutter下的pubspec.yaml都需要運(yùn)行該命令,保證插件的iOS部分同步到iOS項(xiàng)目中。build phase, 方便iOS項(xiàng)目編譯Dart代碼(即my_flutter中的代碼)。步驟:xcode打開iOS項(xiàng)目 -> 選擇左側(cè)跟項(xiàng)目 -> TARGET -> 當(dāng)前項(xiàng)目 -> build phase -> 點(diǎn)加號(hào)添加新的build phase -> 選擇New Run Script Phase -> 將以下代碼復(fù)制到sh文本輸入框中 -> 將新建的build script拖到并緊挨arget Dependencies phase的下邊?,F(xiàn)在應(yīng)該可以?B編譯項(xiàng)目了。"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed GeneratedPluginRegistrant.register(with: self);運(yùn)行可能要蹦。解決方法是:在創(chuàng)建FlutterViewController后才添加代碼GeneratedPluginRegistrant.register(with: fvc),fvc是FlutterViewController的實(shí)例。my_flutter下運(yùn)行flutter attach的話,可以調(diào)試flutter代碼pod install以保證flutter中插件與iOS項(xiàng)目中同步my_flutter下運(yùn)行flutter attach調(diào)試,打印出的http鏈接,可以復(fù)制到瀏覽器中。注意看打印信息,可以發(fā)現(xiàn)更多功能。