swift PR

【SwiftUI】FirebaseUI/Authインストールとエラーの対処

記事内に商品プロモーションを含む場合があります

今回は、SeiftUIでFirebaseUIを利用したログイン機能を実装する際にエラーが出たので解決策を記録します。

忙しい人は、一番したまでスクロールしてくださいませ

【SwiftUI】FirebaseUI/Authインストールとエラーの対処

エラー状況と試みたこと

もともとのPodfileはこちら

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'sample' do
  use_frameworks!
  pod 'Resolver'

  # Pods for firebase-youtube
  pod 'Firebase/Auth'
  pod 'Firebase/Analytics'
  pod 'Firebase/Firestore'
  pod 'FirebaseFirestoreSwift'
  pod 'FirebaseUI/Auth'
  pod 'FirebaseUI/Google'
end

このファイルだと、下記のエラーが出ました

[!] CocoaPods could not find compatible versions for pod "Firebase/Auth":
  In Podfile:
    Firebase/Auth

    FirebaseUI/Auth (>= 10.0.2) was resolved to 10.0.2, which depends on
      Firebase/Auth (>= 7.2.0)

There are only pre-release versions available satisfying the following requirements:

	'Firebase/Auth', '>= 0'

	'Firebase/Auth', '>= 7.2.0'

You should explicitly specify the version in order to install a pre-release version
CocoaPods could not find compatible versions for pod "nanopb":
  In Podfile:
    FirebaseFirestoreSwift was resolved to 0.4.0, which depends on
      FirebaseFirestore (>= 1.6.1, ~> 1.6) was resolved to 1.12.1, which depends on
        nanopb (~> 0.3.901)

    FirebaseUI/Auth (>= 10.0.2) was resolved to 10.0.2, which depends on
      Firebase/Auth (>= 7.2.0) was resolved to 7.2.0, which depends on
        FirebaseAuth (~> 7.2.0) was resolved to 7.2.0, which depends on
          FirebaseCore (~> 7.0) was resolved to 7.2.0, which depends on
            FirebaseCoreDiagnostics (~> 7.0) was resolved to 7.3.0, which depends on
              nanopb (~> 2.30906.0)

どうやら、firebase/authのバージョンがおかしようです。

次の対策、firebase/authのバージョンを指定

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'sample' do
  use_frameworks!
  pod 'Resolver'

  # Pods for firebase-youtube
  pod 'Firebase/Auth', '>= 7.2.0'
  pod 'Firebase/Analytics'
  pod 'Firebase/Firestore'
  pod 'FirebaseFirestoreSwift'
  pod 'FirebaseUI/Auth', '>= 10.0.2'
  pod 'FirebaseUI/Google', '>= 10.0.2'
end

でもなにかおかしい。。。

解決方法

こちらにありました!

https://github.com/firebase/FirebaseUI-iOS/issues/938
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'sample' do
  use_frameworks!
  pod 'Resolver'

  # Pods for firebase-youtube
  pod 'Firebase/Auth'
  pod 'Firebase/Analytics'
  pod 'Firebase/Firestore'
  pod 'FirebaseFirestoreSwift', '= 7.5.0-beta'
  pod 'FirebaseUI/Auth', '>= 10.0.2'
  pod 'FirebaseUI/Google', '>= 10.0.2'
end

誰かの役に立てば幸いです