HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ###### tags: `第13屆IT邦鐵人賽文章` # 【在 iOS 開發路上的大小事-Day13】Firebase 你好啊! # 前情提要 Firebase 是 Google 推出的雲端後端服務平台,提供了行動端 (Android / iOS) 及網頁端 (Web) 的應用服務,擁有即時資料、低維護成本等特色,此外也提供了多種後端服務 (如:驗證服務、資料庫服務、數據分析服務、推播通知服務等) ![](https://i.imgur.com/HsYpTLC.png) [Firebase iOS 開發文檔 (點我)](https://firebase.google.com/docs/ios/setup) # 開始安裝 Firebase 到專案內囉 Firebase 有提供下面這幾種方式可以將其安裝到專案內 1. CocoaPods (官方推薦) 2. 集成 SDK 框架 3. Swift Package Manager 這邊我選擇使用 CocoaPods 來進行安裝 先用 Terminal 切換到專案目錄底下 接著再打開專案內的 Podfile,將你需要用到的 Firebase 服務增加進去 這裡我先將 Firebase 的基本框架新增進去,後面幾天所需要的服務,等到時候再一一添加進來 如果不知道要怎麼加入對應的服務,可以參考[開發文檔底下的說明](https://firebase.google.com/docs/ios/setup#available-pods) ``` pod 'Firebase/Core' ``` ![](https://i.imgur.com/eVTrSca.png) 接著在 Terminal 輸入安裝指令 ``` pod install ``` ![](https://i.imgur.com/nvFKJA3.png) 這樣就算安裝完成了,接著在開啟 `專案名稱.xcworkspace` 切換到 AppDelegate.swift 在最上面引入 Firebase ```swift= import Firebase ``` 在 AppDelegate.swift 裡的「didFinishLaunchingWithOptions」加入下面這一行 ```swift= func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() // 加入這一行 return true } ``` # 到 Firebase Console 設定 打開 [Firebase Console](https://console.firebase.google.com/u/3/),新建一個專案 ![](https://i.imgur.com/5uYjw7m.png) 輸入在 Firebase 的專案名稱 這邊我是取跟 Xcode 專案相同的名稱,這樣會比較好找 ![](https://i.imgur.com/AfjMHKK.png) Firebase 的 Google Analytics 就按繼續 ![](https://i.imgur.com/15GsGaH.png) 設定 Google Analytics 的帳戶,這邊我是跟 Firebase 專案用相同帳戶 ![](https://i.imgur.com/jFd6W3W.png) 接著就可以按下建立專案了,等他跑完,專案就建立好了 建立好之後,就會看到這個 Firebase 專案的後台了 ![](https://i.imgur.com/3xL0txa.png) 點擊畫面中間的 iOS,來將我們的 App 跟 Firebase 連在一起 ![](https://i.imgur.com/aNtLrL2.png) 接著就是把 Xcode 專案的 Bundle Identifier 新增到 Firebase 專案內,填好之後,就按下註冊應用程式 ![](https://i.imgur.com/omNe9JH.png) 接著就照著圖上的指示做就可以了,要注意的是 GoogleService-Info.plist 不要外流,因為這相當是等於專案的 Key,在做 Git 版本控制的時候要注意 ![](https://i.imgur.com/HNR4jG2.png) 第三步是將 Firebase SDK 新增到專案內,這部分前面我們已經做好了,所以就可以略過 ![](https://i.imgur.com/oc8ybej.png) 第四步是在 AppDelegate.swift 裡新增初始化 Code,這部分前面我們也已經做好了,所以就略過 ![](https://i.imgur.com/Y1Wplgm.png) 這樣在 Firebase Console 就算設定完成了 後面幾天,會來分享如何透過 Firebase 來實作登入登出、第三方帳號登入、資料庫服務

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in via Google

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully