一个flutter项目,其实也不是太老,主要是flutter升级的太快,新同事加载flutter项目时,总会遇到这样那样奇奇怪怪的问题,这里记录一下,希望能帮到遇到同样困难的其他同学。
1. 在ios目录下,执行 pod install --clean-install 后,出现架包错误;
错误如下图所示:
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "AgoraRtcEngine_iOS":
In snapshot (Podfile.lock):
AgoraRtcEngine_iOS (= 3.4.6)
In Podfile:
agora_rtc_engine (from `.symlinks/plugins/agora_rtc_engine/ios`) was resolved to 4.0.7, which depends on
AgoraRtcEngine_iOS (= 3.5.0.3)
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* changed the constraints of dependency `AgoraRtcEngine_iOS` inside your development pod `agora_rtc_engine`.
You should run `pod update AgoraRtcEngine_iOS` to apply changes you've made.
[!] Automatically assigning platform `iOS` with version `12.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `[https://guides.cocoapods.org/syntax/podfile.html#platform](https://guides.cocoapods.org/syntax/podfile.html#platform)`.
2.根据提示信息,输入命令:pod install --repo-update
命令输入后,依旧报错,错误信息如下图所示:
Updating local specs repositories
$ /usr/bin/git -C /Users/ioskaifa110/.cocoapods/repos/cocoapods fetch origin --progress
remote: Enumerating objects: 16015, done.
remote: Counting objects: 100% (6919/6919), done.
remote: Compressing objects: 100% (227/227), done.
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
error: 3334 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: index-pack failed
[!] CocoaPods was not able to update the `cocoapods` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
3.依旧报错,根据提示输入命令:pod repo update --verbose
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
Updating spec repo `aliyun-aliyun-specs`
Updating spec repo `cocoapods`
$ /usr/bin/git -C /Users/ioskaifa110/.cocoapods/repos/cocoapods fetch origin --progress
fatal: unable to access '[https://github.com/CocoaPods/Specs.git/](https://github.com/CocoaPods/Specs.git/)': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
[!] CocoaPods was not able to update the `cocoapods` repo. If this is an unexpected issue and persists you can inspect it running `pod repo update --verbose`
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:187:in `rescue in update_git_repo'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:178:in `update_git_repo'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-core-1.11.2/lib/cocoapods-core/source.rb:354:in `update'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:144:in `block (3 levels) in update'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:143:in `block (2 levels) in update'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `each'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:142:in `block in update'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `open'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/sources_manager.rb:140:in `update'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/command/repo/update.rb:23:in `run'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/gems/cocoapods-1.11.2/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `load'
/usr/local/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `<main>'
4.依旧报错,根据提示,再来一次:pod repo update --verbose
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
Updating spec repo `aliyun-aliyun-specs`
Updating spec repo `cocoapods`
$ /usr/bin/git -C /Users/ioskaifa110/.cocoapods/repos/cocoapods fetch origin --progress
remote: Enumerating objects: 16048, done.
remote: Counting objects: 100% (6974/6974), done.
remote: Compressing objects: 100% (199/199), done.
remote: Total 16048 (delta 6769), reused 6950 (delta 6762), pack-reused 9074 Receiving objects: 100% (16048/16048), 2.43 MiB | 3.54 MiB/s, done.
Resolving deltas: 100% (11033/11033), completed with 2320 local objects.
From [https://github.com/CocoaPods/Specs](https://github.com/CocoaPods/Specs)
bcfb480b2a7b..babb3cec1793 master -> origin/master
$ /usr/bin/git -C /Users/ioskaifa110/.cocoapods/repos/cocoapods rev-parse --abbrev-ref HEAD
master
$ /usr/bin/git -C /Users/ioskaifa110/.cocoapods/repos/cocoapods reset --hard origin/master
HEAD is now at babb3cec1793 [Add] AliInteractiveDocumentCore 1.5.0-rc8
Updating spec repo `trunk`
CDN: trunk Relative path downloaded: deprecated_podspecs.txt, save ETag: W/"61bc05f6-8987f"
CDN: trunk Going to update 13 files
CDN: trunk Relative path: all_pods_versions_1_1_7.txt, has ETag? W/"61bbfe1a-9b9"
CDN: trunk Relative path: all_pods_versions_5_d_c.txt, has ETag? W/"61bbfe1a-495"
CDN: trunk Relative path: all_pods_versions_1_d_9.txt, has ETag? W/"61bc040d-8a7"
CDN: trunk Relative path: all_pods_versions_e_9_d.txt, has ETag? W/"61bbfe1a-4d8"
CDN: trunk Relative path: all_pods_versions_b_2_d.txt, has ETag? W/"61b6ff40-57c"
CDN: trunk Relative path: all_pods_versions_1_6_1.txt, has ETag? W/"61bc040d-475"
CDN: trunk Relative path: all_pods_versions_3_7_4.txt, has ETag? W/"61bbfe1a-464"
CDN: trunk Relative path: all_pods_versions_6_f_0.txt, has ETag? W/"61bbfe1a-34a"
CDN: trunk Relative path: CocoaPods-version.yml, has ETag? "61b6ff40-38"
CDN: trunk Relative path: all_pods_versions_c_7_9.txt, has ETag? W/"61bbfe1a-50d"
CDN: trunk Relative path: all_pods_versions_3_7_9.txt, has ETag? W/"61b6ff40-417"
CDN: trunk Relative path: all_pods_versions_f_4_e.txt, has ETag? W/"61bc040d-4bb"
CDN: trunk Relative path: all_pods_versions_1_9_2.txt, has ETag? W/"61bc040d-1bb"
CDN: trunk Relative path downloaded: all_pods_versions_1_1_7.txt, save ETag: W/"61bc07cd-9b9"
CDN: trunk Relative path downloaded: all_pods_versions_1_d_9.txt, save ETag: W/"61bc05f5-8a7"
CDN: trunk Relative path downloaded: all_pods_versions_1_6_1.txt, save ETag: W/"61bc05f5-475"
CDN: trunk Relative path downloaded: all_pods_versions_e_9_d.txt, save ETag: W/"61bc05f5-4d8"
CDN: trunk Relative path downloaded: all_pods_versions_5_d_c.txt, save ETag: W/"61bc05f5-495"
CDN: trunk Relative path downloaded: all_pods_versions_f_4_e.txt, save ETag: W/"61bc05f5-4bb"
CDN: trunk Relative path downloaded: all_pods_versions_b_2_d.txt, save ETag: W/"61bc07cd-57c"
CDN: trunk Relative path downloaded: all_pods_versions_3_7_9.txt, save ETag: W/"61bc07cd-417"
CDN: trunk Relative path downloaded: all_pods_versions_3_7_4.txt, save ETag: W/"61bc05f5-464"
CDN: trunk Relative path downloaded: all_pods_versions_6_f_0.txt, save ETag: W/"61bc05f5-34a"
CDN: trunk Relative path downloaded: all_pods_versions_c_7_9.txt, save ETag: W/"61bc05f5-50d"
CDN: trunk Relative path downloaded: all_pods_versions_1_9_2.txt, save ETag: W/"61bc05f5-1bb"
CDN: trunk Relative path downloaded: CocoaPods-version.yml, save ETag: "61bc07cd-38"
备注:LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443,出现这个错误,一般是网络不好导致 git 连接失败,一般情况下,多更新几次就好了,需要一点点耐心。
5.OK,这次没有报错信息了,去xcode里面看看;
在AndroidStudio选择ios目录,点击右键,选择Xcode打开,在Xcode下确认以下几项:
1).签名确定没有错误,这个非常重要!
target -》signing & capabilities
如果有错,去project -》info -》 configuration 把错误的版本删除再添加,可解决签名错误问题;必须先删除再添加,直接修改可能不起作用。
备注:对于ios端开发来说,签名是否正确非常重要,多个版本的签名,如果有一个版本的签名错了,可能导致一些不可预知的错误。
举个我同事的例子吧。
同一个项目,添加一个插件,我这边是成功的,他那边各种错误,初始化都不能成功,怎么样都解决不了。经过xcode配置对比发现,他的release版本的签名是报错的,把签名重新设置后,插件也可以正常使用了。
2).确定没有包含不必要的配置
target ->build phases->link binary with Libraries下查看,有没有不使用的framework,如果有就去掉;
6. 项目被更新后,再次执行:pod install --clean-install
报错信息如下所示:
Analyzing dependencies
[!] Unable to find a specification for `AlicloudPush (~> 1.9.9)` depended upon by `rammus`
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
[!] Automatically assigning platform `iOS` with version `12.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `[https://guides.cocoapods.org/syntax/podfile.html#platform](https://guides.cocoapods.org/syntax/podfile.html#platform)`.
ioskaifa110@ioskaifadeiMac ios % pod install --repo-update
Updating local specs repositories
Analyzing dependencies
[!] Unable to find a specification for `AlicloudPush (~> 1.9.9)` depended upon by `rammus`
You have either:
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
[!] Automatically assigning platform `iOS` with version `12.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `[https://guides.cocoapods.org/syntax/podfile.html#platform](https://guides.cocoapods.org/syntax/podfile.html#platform)`.
7.根据6的提示,去修改Podfile文件,在头部添加:
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/aliyun/aliyun-specs.git'
备注:这项目使用了阿里云的移动推送,在Podfile配置中,需要加入这两个资源。
8.继续执行 pod install --clean-install
BMKLocationKit.release.xcconfig:1:1: unable to open file (in target "BMKLocationKit" in project "Pods")
上面的命令各自执行来了一遍,错误解决。
9.启动报错
↳
** BUILD FAILED **
Xcode's output:
↳
error: the following command failed with exit code 0 but produced no further output
CompileC /Users/ioskaifa110/....../ios/build/Pods.build/Debug-iphoneos/flutter_local_notifications.build/Objects-normal/arm64/FlutterLocalNotificationsPlugin.o /Users/ioskaifa110/Downloads/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_local_notifications-8.1.1+1/ios/Classes/FlutterLocalNotificationsPlugin.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'flutter_local_notifications' from project 'Pods')
/Users/ioskaifa110/Downloads/flutter/.pub-cache/hosted/pub.flutter-io.cn/webview_flutter-2.0.13/ios/Classes/FlutterWebView.m:395:23: warning: 'requiresUserActionForMediaPlayback' is deprecated: first deprecated in iOS 10.0 [-Wdeprecated-declarations]
configuration.requiresUserActionForMediaPlayback = true;
10.执行5.2,项目中有使用地图,是否缺少地图插件;
排除结果,少了一个系统库文件;
11.报错:Build input file cannot be found: '/Users/ioskaifa110/.../ios/plugins/mobpush/MobpushPlugin.m'
无用的插件没删除干净,到指定目录下删除;
12.报错:/Users/ioskaifa110/rsdun_flutter_app/ios/build/Pods.build/Release-iphoneos/SwiftyGif.build/module.modulemap:9:12: Header 'SwiftyGif-Swift.h' not found
解决办法:https://www.jianshu.com/p/00991deee746,不可以;
https://www.jianshu.com/p/0f6600a0cc67,不可以;
13.清除缓存:product -》clean
解决不了,那就试试清除缓存吧,在AndroidStudio开发中,经常使用这一招废弃缓存信息。
14.错误:Module 'agora_rtc_engine' not found
问题解决解决着,又回到了原点,相关命令在执行一遍。
flutter build iOS (flutter clean ,flutter pub get) 多次后,问题解决;
15.支付宝某个库文件找不到,使用xcode导入,问题解决。
在对接移动推送时,案例中曾写了一句话,请正确导入配置文件。刚开始我忽略了这句话,配置文件拷贝一下不就OK了吗?(当然,我也是ios开发小白,最近才踏进一只脚)
事实却不是这样的,必须使用Xcode的导入功能,xcode才能找到和识别配置文件,拷贝进去是找不到的,这或许和xcode的开发机制有关系吧!这可是我用大量时间换来的宝贵经验,特别适合小白。
最后总结
项目运行不起来,当然很着急,看到密密麻麻的报错信息,也很头疼。但是仔细研究了这些错误之后,发现解决这些错误并不费力,而且有规律可循,那就是根据英文的提示进行解决,有提示命令的运行提示命令即可,这些就可以解决百分之八十的错误了。