Skip to content

Commit ab7aee8

Browse files
committed
Use local emulator
Signed-off-by: Peter Friese <[email protected]>
1 parent e858732 commit ab7aee8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix.xcodeproj/xcshareddata/xcschemes/FriendlyFlix.xcscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
ReferencedContainer = "container:FriendlyFlix.xcodeproj">
5151
</BuildableReference>
5252
</BuildableProductRunnable>
53+
<CommandLineArguments>
54+
<CommandLineArgument
55+
argument = "-useEmulator YES"
56+
isEnabled = "YES">
57+
</CommandLineArgument>
58+
</CommandLineArguments>
5359
</LaunchAction>
5460
<ProfileAction
5561
buildConfiguration = "Release"

Examples/FriendlyFlix/app/FriendlyFlix/FriendlyFlix/App/FriendlyFlixApp.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,29 @@ import FirebaseAuth
1717
import FirebaseDataConnect
1818
import FriendlyFlixSDK
1919
import SwiftUI
20+
import os
2021

2122
@main
2223
struct FriendlyFlixApp: App {
24+
private let logger = Logger(subsystem: "FriendlyFlix", category: "configuration")
25+
2326
var authenticationService: AuthenticationService?
2427

28+
/// Determines whether to use the Firebase Local Emulator Suite.
29+
/// To use the local emulator, go to the active scheme, and add `-useEmulator YES`
30+
/// to the _Arguments Passed On Launch_ section.
31+
public var useEmulator: Bool {
32+
let value = UserDefaults.standard.bool(forKey: "useEmulator")
33+
logger.log("Using the emulator: \(value == true ? "YES" : "NO")")
34+
return value
35+
}
36+
2537
init() {
2638
FirebaseApp.configure()
39+
if useEmulator {
40+
DataConnect.friendlyFlixConnector.useEmulator(port: 9399)
41+
Auth.auth().useEmulator(withHost: "localhost", port:9099)
42+
}
2743

2844
authenticationService = AuthenticationService()
2945
authenticationService?.onSignUp { user in

0 commit comments

Comments
 (0)