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.
image.png
解决办法:flutter已经给出了方案
,各位看官如果不想看官网,我给大家翻译一下:
用xcode 打开项目,找到App.framework 和 Flutter.framework删掉,
然后在Build Phases 和Embed Frameworks 中分别查看 App.framework 和 Flutter.framework 是否还存在,确保这两个地方也已经删掉
framework-build-phase-3eb8ad5f2c65271b70274f285643aa9d6fc38a41732825da831c5f705236d39d.png
然后在 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
1589606551427_6322E143-60A8-4760-A1C4-9725981A0FF0.png接下来在Build Settings 中 Other Linker Flags 添加这个: $(inherited) -framework Flutter
linker-arguments-e0c99015cb970a0e0461c8574b5cf7739f2eeae83565eeb203fb37d6ef632210.png
再次运行项目,就可以了。
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);
image.png
我引入了一个加密的第三方库,这个库里面包含一个类Key 和 系统的库里面的Key 重名了,系统不知道该从哪个库里面取。
解决办法:给引用的第三方库起个别名EncryptLib,使用第三方库的时候在前面加上这个别名,重新编译就好了
image.png
持续更新中...
网友评论