1、新建flutter项目,先在iOS真机上运行,然后在iOS模拟器上运行可能会报错如下(或者先在模拟器上运行然后在真机上运行,报错类似):
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已经给出了方案
,各位看官如果不想看官网,我给大家翻译一下:
用xcode 打开项目,找到App.framework 和 Flutter.framework删掉,
然后在Build Phases 和Embed Frameworks 中分别查看 App.framework 和 Flutter.framework 是否还存在,确保这两个地方也已经删掉
然后在 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 添加这个: $(inherited) -framework Flutter
再次运行项目,就可以了。
2、从GitHub上clone 其他人的项目,在模拟器上运行报错:
[!] 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',然后再次运行项目,就可以了。
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);
我引入了一个加密的第三方库,这个库里面包含一个类Key 和 系统的库里面的Key 重名了,系统不知道该从哪个库里面取。
解决办法:给引用的第三方库起个别名EncryptLib,使用第三方库的时候在前面加上这个别名,重新编译就好了
4、AndroidStudio 设备列表一直显示loading状态:
解决方案:
关闭AndroidStudio(不关闭的话好像不行),找到flutter的安装目录,进入bin/cache目录,找到lockfile文件并且将这个文件删除,终端重新执行flutter doctor,然后再打开AndroidStudio,就可以了。
5、fatal: unable to access 'https://chromium.googlesource.com/webm/libwebp/'解决方法
换了一个电脑环境,把项目clone到本地,运行iOS模拟器的时候一直卡在pod install,cd 到ios 目录运行pod install,发现有个库一直安装失败,
[!] 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了一个副本,把https://chromium.googlesource.com/webm/libwebp 替换为https://github.com/webmproject/libwebp.git 并保存
然后再执行pos install ,如果还是失败,肯能是网络问题,多执行几次就可以了。
持续更新中...