1淮韭、新建flutter項(xiàng)目窗慎,先在iOS真機(jī)上運(yùn)行铺坞,然后在iOS模擬器上運(yùn)行可能會(huì)報(bào)錯(cuò)如下(或者先在模擬器上運(yùn)行然后在真機(jī)上運(yùn)行渤早,報(bào)錯(cuò)類似):
Error output from Xcode build:
?
** BUILD FAILED **
Xcode's output:
?
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
error: Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS. (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
解決辦法:flutter已經(jīng)給出了方案
职车,各位看官如果不想看官網(wǎng),我給大家翻譯一下:
用xcode 打開項(xiàng)目鹊杖,找到App.framework 和 Flutter.framework刪掉悴灵,
然后在Build Phases 和Embed Frameworks 中分別查看 App.framework 和 Flutter.framework 是否還存在,確保這兩個(gè)地方也已經(jīng)刪掉
然后在 Build Phases 中的 Thin Binary 添加如下兩條命令:
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin
接下來在Build Settings 中 Other Linker Flags 添加這個(gè): $(inherited) -framework Flutter
再次運(yùn)行項(xiàng)目骂蓖,就可以了积瞒。
2、從GitHub上clone 其他人的項(xiàng)目涯竟,在模擬器上運(yùn)行報(bào)錯(cuò):
[!] CDN: trunk Repo update failed - 4 error(s):
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/7/9/Reachability/3.0.0/Reachability.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/7/9/Reachability/3.1.0/Reachability.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/7/9/Reachability/3.1.1/Reachability.podspec.json Response: Couldn't connect to server
CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/c/7/9/Reachability/3.2/Reachability.podspec.json Response: Couldn't connect to server
解決方法: 打開ios->podFile文件,在podFile 文件中添加 source 'https://github.com/CocoaPods/Specs.git'空厌,然后再次運(yùn)行項(xiàng)目庐船,就可以了。
3嘲更、Compiler message:
lib/commom/net/http_util.dart:288:21: Error: 'Key' is imported from both 'package:encrypt/encrypt.dart' and 'package:flutter/src/foundation/key.dart'.
final key = Key.fromUtf8(GWR1);
我引入了一個(gè)加密的第三方庫筐钟,這個(gè)庫里面包含一個(gè)類Key 和 系統(tǒng)的庫里面的Key 重名了,系統(tǒng)不知道該從哪個(gè)庫里面取赋朦。
解決辦法:給引用的第三方庫起個(gè)別名EncryptLib篓冲,使用第三方庫的時(shí)候在前面加上這個(gè)別名李破,重新編譯就好了
4、AndroidStudio 設(shè)備列表一直顯示loading狀態(tài):
解決方案:
關(guān)閉AndroidStudio(不關(guān)閉的話好像不行)壹将,找到flutter的安裝目錄嗤攻,進(jìn)入bin/cache目錄,找到lockfile文件并且將這個(gè)文件刪除诽俯,終端重新執(zhí)行flutter doctor妇菱,然后再打開AndroidStudio,就可以了暴区。
5闯团、fatal: unable to access 'https://chromium.googlesource.com/webm/libwebp/'解決方法
換了一個(gè)電腦環(huán)境,把項(xiàng)目clone到本地仙粱,運(yùn)行iOS模擬器的時(shí)候一直卡在pod install房交,cd 到ios 目錄運(yùn)行pod install,發(fā)現(xiàn)有個(gè)庫一直安裝失敗,
[!] Error installing libwebp
[!] /usr/local/bin/git clone https://chromium.googlesource.com/webm/libwebp /var/folders/cn/cg4r_mnn7h3fkznjlm7vqtxc0000gn/T/d20180820-45387-i7eiac --template= --single-branch --depth 1 --branch v1.0.0
Cloning into '/var/folders/cn/cg4r_mnn7h3fkznjlm7vqtxc0000gn/T/d20180820-45387-i7eiac'...
fatal: unable to access 'https://chromium.googlesource.com/webm/libwebp/': Failed to connect to chromium.googlesource.com port 443: Operation timed out
解決方案:前往cocospods 緩存庫文件目錄:~/.cocoapods/repos/edu-git-cocoapods-specs/Specs/1/9/2/libwebp,Mac電腦的版本不同伐割,目錄可能稍有差別候味,反正就是找到libwebp的緩存地址,找到最新版本口猜,1.2.0负溪,將里面的配置文件git 地址換一下,在操作之前為了防止有誤济炎,我copy了一個(gè)副本川抡,把https://chromium.googlesource.com/webm/libwebp 替換為https://github.com/webmproject/libwebp.git 并保存
然后再執(zhí)行pos install ,如果還是失敗,肯能是網(wǎng)絡(luò)問題须尚,多執(zhí)行幾次就可以了崖堤。
持續(xù)更新中...