ios端开发,加载Flutter老项目后,各种报错解决

一个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的开发机制有关系吧!这可是我用大量时间换来的宝贵经验,特别适合小白。

最后总结
项目运行不起来,当然很着急,看到密密麻麻的报错信息,也很头疼。但是仔细研究了这些错误之后,发现解决这些错误并不费力,而且有规律可循,那就是根据英文的提示进行解决,有提示命令的运行提示命令即可,这些就可以解决百分之八十的错误了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 195,898评论 5 462
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 82,401评论 2 373
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 143,058评论 0 325
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,539评论 1 267
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,382评论 5 358
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,319评论 1 273
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,706评论 3 386
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,370评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,664评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,715评论 2 312
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,476评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,326评论 3 313
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,730评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,003评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,275评论 1 251
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,683评论 2 342
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,877评论 2 335

推荐阅读更多精彩内容