1. 檢查是否安裝flutter
??? 終端輸入?
flutter --version
結(jié)果:
Flutter 1.5.4-hotfix.2 ? channel stable ? https://github.com/flutter/flutter.git
Framework ? revision 7a4c33425d (4 weeks ago) ? 2019-04-29 11:05:24 -0700
Engine ? revision 52c7a1e849
Tools ? Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
bogon:flutter_module tanibon$
2. 設(shè)置鏡像?? vi ~/.bash_profile?
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
3. 終端cd 到 原生app 的 XXXX.xcodeproj運(yùn)行目錄上一級(jí) 創(chuàng)建flutter module
flutter create-t module XXXXX
結(jié)果:http://www.reibang.com/p/af085d4420fd
4. 原生app創(chuàng)建podfile 在最后加入腳本
flutter_application_path ='../xxxxxxxx 'eval(File.read(File.join(flutter_application_path,'.ios','Flutter','podhelper.rb')), binding)
執(zhí)行podinstall
5. 添加腳本文件
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
6. 把Enable Bitcode設(shè)為NO,F(xiàn)lutter混合開發(fā)還不支持bit code,所以在iOS工程檢查項(xiàng)目并關(guān)閉bit code
7. 修改AppDelegate.h舰褪、AppDelegate.m
8. 熱更新 Hot Reload
? cd到flutter工程路徑嗅义,執(zhí)行flutter attach
? attach成功之后昧识,運(yùn)行xcode,更新直接press 'r'