LoginSignup
6
3

More than 3 years have passed since last update.

swiftでFirebaseAppがクラスとして認識されない問題の解決

Last updated at Posted at 2019-04-28

問題

pod 'Firebase/Core'した後、FirebaseApp.configure()を書いても、
Use of unresolved identifier 'FirebaseApp'というエラーでFirebaseAppがクラスとして認識されない。

AppDelegate.swift
import UIKit
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {

    var window: UIWindow?


    // [START didfinishlaunching]
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]?) -> Bool {
        FirebaseApp.configure()

        return true
    }

原因

古いバージョンのFirebaseCoreがインストールされていた。
何かしらが原因で3.x.xがインストールされていた。
どうやら'FirebaseApp'は4.x.x以降でないと定義されていないらしい。

問題のPodfile.lockファイル↓

Podfile.lock
Firebase/Core (3.17.0):
    - FirebaseAnalytics (= 3.9.0)
    - FirebaseCore (= 3.6.0)
  - FirebaseAnalytics (3.9.0):
    - FirebaseCore (~> 3.6)
    - FirebaseInstanceID (~> 1.0)
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
  - FirebaseCore (3.6.0):
    - "GoogleToolboxForMac/NSData+zlib (~> 2.1)"
  - FirebaseInstanceID (1.0.10):
    - FirebaseCore (~> 3.6)

解決策

一旦Podfile.lockファイルを削除。
pod repo updatepod updateをして、podを最新にする

依存関係とかでごちゃらないように、podfileにはpod 'Firebase/Core'だけを記述してpod installする。
これで最新のFirebaseCoreと、関連のライブラリがインストールされるはず。
一度最新をインストールすればPodfile.lockファイルも最新のものが固定されるため、他のライブラリを入れても大乗なはず

なぜ古いバージョンがインストールされたか

pod 'GoogleAPIClientForREST/Sheets'
pod 'Google/SignIn'

をインストールすると古いFirebaseCoreがついてくるようだ。
G Suite APIs for iOSはドキュメントも適当だし、メンテされてない感が満載だから、古い依存関係のままインストールされたのだろう...

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3