File tree Expand file tree Collapse file tree 4 files changed +11
-21
lines changed
Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix Expand file tree Collapse file tree 4 files changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -20,30 +20,13 @@ import SwiftUI
2020
2121@main
2222struct FriendlyFlixApp : App {
23- private func loadRocketSimConnect( ) {
24- #if DEBUG
25- guard Bundle (
26- path: " /Applications/RocketSim.app/Contents/Frameworks/RocketSimConnectLinker.nocache.framework "
27- ) ?
28- . load ( ) == true else {
29- print ( " Failed to load linker framework " )
30- return
31- }
32- print ( " RocketSim Connect successfully linked " )
33- #endif
34- }
35-
3623 var authenticationService : AuthenticationService ?
3724
3825 init ( ) {
39- loadRocketSimConnect ( )
4026 FirebaseApp . configure ( )
4127
4228 authenticationService = AuthenticationService ( )
4329 authenticationService? . onSignUp { user in
44- print (
45- " User signed in \( user. displayName ?? " (no fullname) " ) with email \( user. email ?? " (no email) " ) "
46- )
4730 let userName = String ( user. email? . split ( separator: " @ " ) . first ?? " (unknown) " )
4831 Task {
4932 try await DataConnect . friendlyFlixConnector. upsertUserMutation. execute ( username: userName)
Original file line number Diff line number Diff line change 1414
1515import AuthenticationServices
1616import SwiftUI
17+ import os
1718
1819private enum FocusableField : Hashable {
1920 case email
@@ -27,6 +28,7 @@ private enum AuthenticationFlow {
2728}
2829
2930struct AuthenticationScreen : View {
31+ private let logger = Logger ( subsystem: " FriendlyFlix " , category: " auth " )
3032 @Environment ( AuthenticationService . self) var authenticationService
3133 @Environment ( \. colorScheme) private var colorScheme
3234 @Environment ( \. dismiss) private var dismiss
@@ -61,7 +63,7 @@ struct AuthenticationScreen: View {
6163 try await authenticationService. signInWithEmailPassword ( email: email, password: password)
6264 dismiss ( )
6365 } catch {
64- print ( error. localizedDescription)
66+ logger . error ( " Error when signing in with email / password: \( error. localizedDescription) " )
6567 errorMessage = error. localizedDescription
6668 }
6769 }
@@ -74,7 +76,7 @@ struct AuthenticationScreen: View {
7476 errorMessage = " "
7577 dismiss ( )
7678 } catch {
77- print ( error. localizedDescription)
79+ logger . error ( " Error when signing up with email / password: \( error. localizedDescription) " )
7880 errorMessage = error. localizedDescription
7981 }
8082 }
Original file line number Diff line number Diff line change 1515import FirebaseAuth
1616import Foundation
1717import Observation
18+ import os
1819
1920enum AuthenticationState {
2021 case unauthenticated
@@ -24,6 +25,8 @@ enum AuthenticationState {
2425
2526@Observable
2627class AuthenticationService {
28+ private let logger = Logger ( subsystem: " FriendlyFlix " , category: " auth " )
29+
2730 var presentingAuthenticationDialog = false
2831 var presentingAccountDialog = false
2932
@@ -57,6 +60,7 @@ class AuthenticationService {
5760 try await Auth . auth ( ) . createUser ( withEmail: email, password: password)
5861
5962 if let onSignUp, let user = Auth . auth ( ) . currentUser {
63+ logger. debug ( " User signed in \( user. displayName ?? " (no fullname) " ) with email \( user. email ?? " (no email) " ) " )
6064 onSignUp ( user)
6165 }
6266
Original file line number Diff line number Diff line change @@ -16,8 +16,10 @@ import FirebaseDataConnect
1616import FriendlyFlixSDK
1717import NukeUI
1818import SwiftUI
19+ import os
1920
2021struct MovieCardView : View {
22+ private let logger = Logger ( subsystem: " FriendlyFlix " , category: " moviecard " )
2123 @Environment ( \. dismiss) private var dismiss
2224 private var connector = DataConnect . friendlyFlixConnector
2325
@@ -32,7 +34,6 @@ struct MovieCardView: View {
3234 }
3335
3436 // MARK: - Favourite handling
35-
3637 private let isFavouriteRef : QueryRefObservation <
3738 GetIfFavoritedMovieQuery . Data ,
3839 GetIfFavoritedMovieQuery . Variables
@@ -132,7 +133,7 @@ extension MovieCardView {
132133 do {
133134 let _ = try await isFavouriteRef. execute ( )
134135 } catch {
135- print ( error)
136+ logger . error ( " Error when trying to fetch favourite status: \( error. localizedDescription ) " )
136137 }
137138 }
138139 }
You can’t perform that action at this time.
0 commit comments