I really would like to write some integration tests using a local firebase-server installation that will simulate a real-time database server.
I installed it and started with the CLI:
node_modules/.bin/firebase-server -p 5000
But I have problems connecting to it through Swift. Following the documents for Firebase, you need to download the utility GoogleService-Info.plistin the project. This obviously needs to change as I want to connect to the local server.
This is what I have right now in AppDelegate.swift:
var firebaseConfig: String!
if isRunningTests() {
firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info-tests", ofType: "plist")
} else {
#if DEBUG
firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")
#else
firebaseConfig = Bundle.main.path(forResource: "GoogleService-Info-prod", ofType: "plist")
#endif
}
guard let options = FIROptions(contentsOfFile: firebaseConfig) else {
fatalError("Invalid Firebase configuration file.")
}
FIRApp.configure(with: options)
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
FIRDatabase.database().persistenceEnabled = true
, plist GoogleService-Info-tests . ws://test.firebase.localhost:5000? , options .