怠慢プログラマーの備忘録

怠慢でナマケモノなプログラマーの備忘録です。

XcodeのプロジェクトにFirebaseRTDBを使う時の初期設定

今回、Map上でのToDoListを管理するアプリを作ってみることにしました。

(なんか以前お仕事やらせてもらった時のを結構参考にさせてもらっています、すいません)

そこでGoogleのFirebaseRTDBを使用しますのでその際の初期設定のメモ。

xcodeのプロジェクト作成

f:id:ka0in:20171026014248p:plain

Organization Identifierに関してはこちらのブログが参考になります。

type.jp

あとはSigningをApple Devに登録したアカウントに設定する。

f:id:ka0in:20171026014637p:plain

これでビルド自体は通るはず。

Firebaseのプロジェクトを作成

f:id:ka0in:20171026014942p:plain

つぎはiOSアプリを作成

f:id:ka0in:20171026015109p:plain

ここでダウンロードできるplistをxcodeのプロジェクトファイルのルートに追加する。

f:id:ka0in:20171026015144p:plain

podfile作成

xcodeprojがあるディレクトリで以下のコマンドを実行

$ pod init

するとpodfileが作成されるので、以下の通りに変更する。

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

target 'todo-map-ios' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for todo-map-ios
    pod 'Firebase/Database’

  target 'todo-map-iosTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'todo-map-iosUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

次に以下のコマンドを実行する。

$ pod install

そうすると下記のような白いアイコンが作成されるので、それでXcodeを立ち上げる。

f:id:ka0in:20171026020942p:plain

そうするとPodsというディレクトリが作られ、Firebaseがあることが確認できます。

f:id:ka0in:20171026021559p:plain

AppDelegateの設定

AppDelegate.swiftで以下のようにします。

// Use Firebase library to configure APIs
import UIKit
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        
        // Use Firebase library to configure APIs
        FirebaseApp.configure()
        return true
    }

    ...

}

次回は画面にGoogleMapを表示させてみます。

モバイルアプリ開発エキスパート養成読本 (Software Design plusシリーズ) [ 山戸茂樹 ]

価格:2,138円
(2017/10/26 02:18時点)
感想(0件)