Flutter iOS混編踩坑記

混編配置能夠參考這篇文章 www.jianshu.com/p/eee692736…xcode

最近開始在項目的邊緣模塊中嘗試使用Flutter開發,對混編過程當中遇到的問題作了一些記錄。bash

一、使用了cocoapods

在Debug.xcconfig和Release.xcconfig裏面添加 注意FlutterMixed 是本身iOS項目的名稱app

#include "Pods/Target Support Files/Pods-FlutterMixed/Pods-FlutterMixed.debug.xcconfig"
#include "Pods/Target Support Files/Pods-FlutterMixed/Pods-FlutterMixed.release.xcconfig"
複製代碼

二、找不到FLUTTER_ROOT

在項目中手動添加文件目錄ui

open Project Target and add User-Defined Setting with key name FLUTTER_ROOTwith the value of your flutter SDK location.spa

三、The path lib/main.dart does not existdebug

config文件的../../路徑問題code

四、dyld: Library not loaded: @rpath/Flutter.framework/Fluttercdn

五、debug環境 跳轉黑屏blog

移除App.framework圖片

六、Flutter doctor ,Flutter upgrade 等卡住

掛終端ss

export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;
複製代碼

端口不必定相同,根據本身的ss配置修改

七、xcode運行腳本卡住

用Android studio 運行一次flutter應用

八、iOS風格的AppBar

return new Scaffold(        
        appBar: new CupertinoNavigationBar(
          middle: new Text('test'),
          trailing: Material(child: IconButton(icon: Icon(Icons.settings))),      
        ),

        body: Text('test'),
);
複製代碼

九、release包 不加載圖片資源

1.更新flutter 版本

flutter upgrade
複製代碼

2.刪除原生項目中的App.framework及Flutter.framework文件從新添加

注:Flutter在1.2版本中將flutter_assets 文件夾的內容移到了App.framework中,不須要再將flutter_assets文件添加至原生工程中

十、上傳App Store 包含[x86_64]報錯

App Store Connect Operation Error
ERROR ITMS-90087: "Unsupported Architectures. The executable for LoanCalculator.app/Frameworks/Flutter.framework contains unsupported architectures '[x86_64]'."

App Store Connect Operation Error
ERROR ITMS-90209: "Invalid Segment Alignment. The app binary at 'LoanCalculator.app/Frameworks/Flutter.framework/Flutter' does not have proper segment alignment. Try rebuilding the app with the latest Xcode version."

App Store Connect Operation Error
ERROR ITMS-90125: "The binary is invalid. The encryption info in the LC_ENCRYPTION_INFO load command is either missing or invalid, or the binary is already encrypted. This binary does not seem to have been built with Apple's linker."
複製代碼

解決方法

1.打開終端

2.cd到Flutter.framework文件夾

example : cd /Users/MAC/Desktop/Flutter/Flutter.framework
複製代碼

3.執行下面代碼

lipo -remove x86_64 Flutter -o Flutter
複製代碼

4.從新打開項目 Clean, Build & Run and Create Archive

ps:

目前項目只是不多的一部分嘗試用Flutter來寫,遇到的問題就上面這些,後面踩到坑會陸續添加進來。我的對Flutter技術十分看好,可是目前就使用體驗來說,我以爲距離iOS原生還有不小的差距,讓iOS有了安卓味,這可不太好,但願後面會更完善吧。

相關文章
相關標籤/搜索