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

解決辦法:http://www.lxweimin.com/p/00991deee746,不可以;
http://www.lxweimin.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閱讀 227,572評論 6 531
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,071評論 3 414
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 175,409評論 0 373
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,569評論 1 307
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,360評論 6 404
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 54,895評論 1 321
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 42,979評論 3 440
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,123評論 0 286
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 48,643評論 1 333
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,559評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 42,742評論 1 369
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,250評論 5 356
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 43,981評論 3 346
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,363評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,622評論 1 280
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,354評論 3 390
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 47,707評論 2 370

推薦閱讀更多精彩內容