🐞

Podfileの概要とエラー対処まとめ 【Flutter / Dart / CocoaPods】

2021/10/02に公開

はじめまして、ますみです!

株式会社Galirage(ガリレージ)という「生成AIのシステム開発会社」で、代表をしております^^

自己紹介.png

Flutterでflutter runflutter build iospod installなどのコマンドを実行した際、podsがうまく入らないことがあります。

私はここで少しだけ苦戦したため、他の困っている方々に向けてログを残します🦅

CocoaPodsとは?

CocoaPodsとは、iOSのスマホアプリやmacOSのデスクトップアプリなどを作る際の「ライブラリ管理をしてくれるツール」です。余談ですが、macOSに初期搭載されているrubyのパッケージ(gem)の一つです。また、podはCocoaPodsのコマンドを実行する際のコマンドになります(一つ一つのライブラリのことも指します)。

https://qiita.com/satoken0417/items/479bcdf91cff2634ffb1

PodfileとPodfile.lockとは?

CocoaPodsにおけるPodfileとPodfile.lockの意味をまず確認しましょう。
Podfileは「ライブラリのバージョン指定などをするファイル」です。
Podfile.lockは「ロック(固定)されたバージョンの情報が格納されているファイル」です。.lockファイルは、pod initpod install時に自動生成されます。

https://note.com/iga34engineer/n/n12a5404543e1

エラー内容と対処法

具体的なエラー内容は、以下の二つです。

1. Please specify a platformと優しく怒られる 😇

error_01
Error output from CocoaPods:
↳
    [!] Automatically assigning platform `iOS` with version `9.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`.
  • こちらのバグは、ios/Podfileの2行目の// platform :ios, '9.0'がコメントになっていることが原因のバグです。
  • そのため、コメントを外すと、エラーは消えるため、以下のようにios/Podfileを編集しましょう。
ios/Podfile
# Uncomment this line to define a global platform for your project
-  // platform :ios, '9.0'
+  platform :ios, '9.0'
  • もしもios/Podfile.lockがある場合は、以下のコマンドも実行しましょう。
% cd ios
% rm Podfile.lock
% sudo gem install cocoapods
Passwords: {ログイン用のパスワードを入力}
% pod repo update
% pod update
% pod install

2. CocoaPods could not find compatible versions for pod "cloud_firestore"と少し厳しめに怒られる 😲

error_02
% flutter build ios
Running "flutter pub get" in flutter_project...                       858ms
Building dev.masumi.flutterProject for device (ios-release)...
Automatically signing iOS for device deployment using specified development team in Xcode project: F39HGSSES
Running pod install...                                           1,513ms
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
    cloud_firestore: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
    -> Fetching podspec for `cloud_functions` from `.symlinks/plugins/cloud_functions/ios`
    cloud_functions: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
    firebase_auth: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '8.7.0' defined in 'firebase_core'
    -> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in
      repo update
    [!] CocoaPods could not find compatible versions for pod "cloud_firestore":
      In Podfile:
        cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)

    Specs satisfying the `cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)` dependency were found, but
    they required a higher minimum deployment target.
  • このエラーは、cloud_firestoreios: 9.0に対応していないということがエラーでした。
  • Podfileのiosのバージョンを上げるとpod installのプロセスを通過できます。
ios/Podfile
# Uncomment this line to define a global platform for your project
-  platform :ios, '9.0'
+  platform :ios, '12.0'

最後に

最後まで読んでくださり、ありがとうございました!
この記事を通して、少しでもあなたの学びに役立てば幸いです!

おまけ①:生成AIエンジニア塾

より専門的な「生成AIエンジニア人材」を目指しませんか?

そんな方々に向けて、「生成AIエンジニア塾」というプログラムを始めました🎉

最終的なゴールとして、『エンタープライズ向けの生成AIシステムを構築するためのスキルを習得し、大手案件で活躍できる人材』を目標とします。

また、一人一人にしっかりと向き合って、メンタリングをできるようにするため、現在メンバーの人数制限をしております。本気度やスキルレベルの高い人から、順番にご案内しております。

▼ 登録はこちらから ▼
https://bit.ly/generative_ai_engineer_school_by_zenn

おまけ②:AI Newsletter for Biz

最新のAIニュースの情報を収集しませんか?

AI Newsltter for Bizは、ビジネスパーソン向けに「AIニュース」を定期配信する完全無料のニュースレターです📩

一人でも多くの方にとって、「AI人材としてのスキルアップ」につながれば幸いです^^

また、現在、登録者限定で「明日から使える 無料AIサービス3選」のPDFを配布中です 🎁
※ ご登録完了のメールに、PDFリンクを添付いたします。

期間限定のプレゼントとなりますので、ぜひ、お早めにご登録ください!

▼ 登録はこちらから ▼
https://bit.ly/ai_newsletter_for_biz_zenn

Discussion