https://console.firebase.google.com/
https://github.com/firebase/firebase-ios-sdk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | / / / / Firebase_AuthApp.swift / / Firebase Auth / / / / Created by Cairocoders / / import SwiftUI import Firebase @main struct Firebase_AuthApp: App { init() { FirebaseApp.configure() } var body: some Scene { WindowGroup { ContentView() } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | / / / / ContentView.swift / / Firebase Auth / / / / Created by Cairocoders / / import SwiftUI import Firebase struct ContentView: View { @State var email = "" @State var password = "" var body: some View { VStack { TextField( "Email" , text: $email) SecureField( "Password" , text: $password) Button(action: { login() }) { Text( "Sign In" ) } } .padding() } func login(){ Auth.auth().signIn(withEmail: email, password: password) { result, error in if error ! = nil { print (error?.localizedDescription ?? "") } else { print ( "success" ) } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |