目录
目录README.md

Firebase Authentication Boilerplate App for iOS

Swift iOS project template that handles authentication with email/password, Sign in with Google, and Sign in with Apple. It contains iOS 16 SwiftUI features such as the new Navigation system, and the code is architected in a way that is scalable if you want to build onto this boilerplate. This template also includes a basic form of persisted sign-in.

Setup

  1. Clone this repo, or copy the entirety of this project folder to your repo https://github.com/tmaasen/iOS-SwiftUI-Firebase-Login-Template/tree/main/iOS-SwiftUI-Firebase-Login-Template.
  2. If you cloned the repo, add your own Bundle ID in the project configuration.
  3. If you cloned the repo, the following dependencies should already be in added to your project via Swift Package Manager (SPM). If you want to use CocoaPods, add the below dependencies to your PodFile.

Dependencies

  1. Create a new project in Firebase, and then add a new Apple App (for further instruction see Firebase Setup for iOS). You will need the auto-generated GoogleService-Info.plist file to run this project.
  2. Add Email/Password, Sign in with Google, and Sign in with Apple Sign-In Methods on your Firebase project once setup (under Authentication > Sign-In Methods tab)

Sign-In Methods

Sign in with Google

  1. Add a new GIDClientID property under Targets > Info > Custom macOS Application Target Properties in XCode
  • Hover over the list of existing properties, right click, Add Row. Let the key = “GIDClientID”, tab over to the value cell, and paste in the CLIENT_ID from your GoogleService-Info.plist configuration file.
  1. Add custom URL scheme to your Xcode project:
  • Open your project configuration: click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section.
  • Click the + button, and add a URL scheme for your reversed client ID. To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key. Copy the value of that key, and paste it into the URL Schemes box on the configuration page. Leave the other fields blank.
  • Documentation reference: Get started with Google Sign-In for iOS

Google Config

Sign in with Apple

  1. In your Apple Developer Account, add a new Identifier to your project. Then, add Sign In with Apple to your app’s id configuration at https://developer.apple.com/account/resources/identifiers/list

AppleDevSetup

  1. Ensure that Sign in with Apple is already added to your project’s capabilities. If not, you will need to add it.
  • NOTE: I added the Keychain Sharing capability because it gets rid of some console warnings and fixes a bug when signing in with Email/Password, but functionality for using the Apple Keychain is not included in this template.

Capabilities Keychain

References

Special thanks goes out to Joseph Hinkle and his repo https://github.com/joehinkle11/Login-with-Apple-Firebase-SwiftUI which was my main reference for this project.

If you want to configure your Firebase App further, go to Google Cloud Console and you should find the project you just created in Firebase. This can be helpful for creating API restrictions if you so desire.

关于
1.2 MB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号