編譯framework
https://github.com/flutter/engine/blob/master/CONTRIBUTING.md
編譯release
debug
ninja -C out/ios_debug_unopt && ninja -C out/host_debug_unopt
release
$ ninja -C out/ios_release_unopt && ninja -C out/host_release_unopt
指定engine版本運(yùn)行 flutter run
$../../bin/flutter run --local-engine-src-path /Users/boo/Documents/engine/engine/src/out/ios_debug --local-engine=ios_debug_unopt
$ flutter run --local-engine-src-path /Users/boo/Documents/engine/engine/src --local-engine=ios_debug_unopt
flutter packages get --local-engine-src-path /Users/boo/Documents/engine/engine/src --local-engine=ios_debug_sim_unopt -d XXXX
//運(yùn)行flutter
$ flutter run --local-engine-src-path /Users/boo/Documents/engine/engine/src --local-engine=ios_debug_sim_unopt -d XXXX
修改完源代碼添加runscript
image.png
cd /Users/boo/Documents/engine/engine/src
ninja -C out/ios_debug_unopt && ninja -C out/host_debug_unopt
cp -rf /Users/boo/Documents/engine/engine/src/out/ios_debug_unopt/Flutter.framework /Users/boo/Documents/demo/flutterbeta/flutterOnExistApp_SelfEngine/Flutter/engine
作用是重新編譯framework使其生效
注意這里的debug认境,release较剃,或模擬器目錄要設(shè)正確,否則編譯不過挽霉,下次生效
打開
設(shè)置xcode斷點(diǎn)
image.png
initWithFlutterAssets:dartMain:packages:
hellobooob
修改資源加載路徑
修復(fù)循環(huán)引用
image.png
image.png
常見錯(cuò)誤
image.png
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FlutterAppDelegate", referenced from:
_OBJC_CLASS_$_AppDelegate in AppDelegate.o
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in libpackage_info.a(PackageInfoPlugin.o)
"_OBJC_METACLASS_$_FlutterAppDelegate", referenced from:
_OBJC_METACLASS_$_AppDelegate in AppDelegate.o
"_FlutterMethodNotImplemented", referenced from:
-[FLTPackageInfoPlugin handleMethodCall:result:] in libpackage_info.a(PackageInfoPlugin.o)
"_OBJC_CLASS_$_FlutterViewController", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
flutter.framework編譯版本問題翩蘸,需要重新編譯或使用舊的替換先
[VERBOSE-1:callback_cache.cc(132)] Could not parse callback cache, aborting restore
2018-10-18 16:47:21.434650+0800 flutterOnExistApp[33371:13930425] [VERBOSE-2:shell.cc(181)] Dart Error: Can't load Kernel binary: Invalid kernel binary format version.
2018-10-18 16:47:21.434875+0800 flutterOnExistApp[33371:13930425] [VERBOSE-2:engine.cc(157)] Could not prepare to run the isolate.
2018-10-18 16:47:21.435723+0800 flutterOnExistApp[33371:13930425] [VERBOSE-2:engine.cc(116)] Engine not prepare and launch isolate.
2018-10-18 16:47:21.436000+0800 flutterOnExistApp[33371:13930425] [VERBOSE-2:FlutterViewController.mm(462)] Could not launch engine with configuration.
2018-10-18 16:47:21.554817+0800 flutterOnExistApp[33371:13930431] flutter: Observatory listening on http://127.0.0.1:54038/
還是flutter.framework 編譯版本問
題
出現(xiàn)錯(cuò)誤
You must specify --local-engine if you are using a locally built engine.
image.png
提示出錯(cuò)了所意,engin少了一個(gè)e 應(yīng)該是engine
$ flutter packages get --local-engine=ios_debug_unopt
$ flutter run --local-engine=ios_debug_unopt
問題
image.png
Unable to detect local Flutter engine build directory.
Either specify a dependency_override for the sky_engine package in your pubspec.yaml and
ensure --package-root is set if necessary, or set the $FLUTTER_ENGINE environment variable, or
use --local-engine-src-path to specify the path to the root of your flutter/engine repository.
Failed to package /Users/boo/Documents/demo/flutterbeta/flutterOnExistApp_SelfEngine/myflutter.
Command /bin/sh failed with exit code 255
重新執(zhí)行
pod update
其他不通過情況再嘗試使用
flutter packages get
flutter run
問題:
2018-10-18 21:24:03.474221+0800 flutterOnExistApp[54577:15146469] [VERBOSE-2:shell.cc(182)] Dart Error: Can't load Kernel binary: Invalid kernel binary format version.
2018-10-18 21:24:03.474442+0800 flutterOnExistApp[54577:15146469] [VERBOSE-2:engine.cc(174)] Could not prepare to run the isolate.
2018-10-18 21:24:03.474760+0800 flutterOnExistApp[54577:15146469] [VERBOSE-2:engine.cc(121)] Engine not prepare and launch isolate.
2018-10-18 21:24:03.475266+0800 flutterOnExistApp[54577:15146469] [VERBOSE-2:FlutterViewController.mm(486)] Could not launch engine with configuration.
2018-10-18 21:24:03.522773+0800 flutterOnExistApp[54577:15146476] flutter: Observatory listening on http://127.0.0.1:56060/
flutter 和 engine版本不一致
需要更新到一致狀態(tài)
使用命令
flutter upgrade
建了個(gè)qq群,大家有問題可以繼續(xù)在里面討論 217429001