Skip to content

Commit

Permalink
Add Firebase Configuration (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer authored Feb 24, 2023
1 parent 1246110 commit 01a1cd5
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 27 deletions.
25 changes: 25 additions & 0 deletions PAWS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
2F9056D5299E1B9C003D3802 /* FirestoreDataStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 2F9056D4299E1B9C003D3802 /* FirestoreDataStorage */; };
2F9056D7299E1B9C003D3802 /* FirestoreStoragePrefixUserIdAdapter in Frameworks */ = {isa = PBXBuildFile; productRef = 2F9056D6299E1B9C003D3802 /* FirestoreStoragePrefixUserIdAdapter */; };
2F9056DB299E1C97003D3802 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2F9056D9299E1C97003D3802 /* GoogleService-Info.plist */; };
2FABBC5929A8975900DF3BBC /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 2FABBC5829A8975900DF3BBC /* FirebaseFirestore */; };
2FABBC5B29A8975900DF3BBC /* FirebaseFirestoreSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 2FABBC5A29A8975900DF3BBC /* FirebaseFirestoreSwift */; };
2FC9759F2978E39600BA99FE /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2FC9759E2978E39600BA99FE /* Localizable.strings */; };
2FC975A82978F11A00BA99FE /* Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FC975A72978F11A00BA99FE /* Home.swift */; };
3637947E2992F3B000B3C006 /* PAWSLandingScreen in Frameworks */ = {isa = PBXBuildFile; productRef = 3637947D2992F3B000B3C006 /* PAWSLandingScreen */; };
Expand Down Expand Up @@ -89,6 +91,8 @@
2F49B7822980419C00BCB272 /* Questionnaires in Frameworks */,
2F49B77E2980407C00BCB272 /* Scheduler in Frameworks */,
2F9056D3299E1B9C003D3802 /* FHIRToFirestoreAdapter in Frameworks */,
2FABBC5B29A8975900DF3BBC /* FirebaseFirestoreSwift in Frameworks */,
2FABBC5929A8975900DF3BBC /* FirebaseFirestore in Frameworks */,
3637947E2992F3B000B3C006 /* PAWSLandingScreen in Frameworks */,
2F9056D5299E1B9C003D3802 /* FirestoreDataStorage in Frameworks */,
2F59B93F298C628800C5107F /* PAWSMockDataStorageProvider in Frameworks */,
Expand Down Expand Up @@ -231,6 +235,8 @@
2F9056D2299E1B9C003D3802 /* FHIRToFirestoreAdapter */,
2F9056D4299E1B9C003D3802 /* FirestoreDataStorage */,
2F9056D6299E1B9C003D3802 /* FirestoreStoragePrefixUserIdAdapter */,
2FABBC5829A8975900DF3BBC /* FirebaseFirestore */,
2FABBC5A29A8975900DF3BBC /* FirebaseFirestoreSwift */,
);
productName = TemplateApplication;
productReference = 653A254D283387FE005D4D48 /* PAWS.app */;
Expand Down Expand Up @@ -312,6 +318,7 @@
2F49B7742980407B00BCB272 /* XCRemoteSwiftPackageReference "CardinalKit" */,
2F4E237F2989C5930013F3D9 /* XCRemoteSwiftPackageReference "XCTHealthKit" */,
2F36AD25299D989F00B1077C /* XCRemoteSwiftPackageReference "XCTestExtensions" */,
2FABBC5729A8975900DF3BBC /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
);
productRefGroup = 653A254E283387FE005D4D48 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -771,6 +778,14 @@
minimumVersion = 0.3.1;
};
};
2FABBC5729A8975900DF3BBC /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 10.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -855,6 +870,16 @@
package = 2F49B7742980407B00BCB272 /* XCRemoteSwiftPackageReference "CardinalKit" */;
productName = FirestoreStoragePrefixUserIdAdapter;
};
2FABBC5829A8975900DF3BBC /* FirebaseFirestore */ = {
isa = XCSwiftPackageProductDependency;
package = 2FABBC5729A8975900DF3BBC /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseFirestore;
};
2FABBC5A29A8975900DF3BBC /* FirebaseFirestoreSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 2FABBC5729A8975900DF3BBC /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
productName = FirebaseFirestoreSwift;
};
3637947D2992F3B000B3C006 /* PAWSLandingScreen */ = {
isa = XCSwiftPackageProductDependency;
productName = PAWSLandingScreen;
Expand Down
6 changes: 0 additions & 6 deletions PAWS.xcodeproj/xcshareddata/xcschemes/PAWS.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@
ReferencedContainer = "container:PAWS.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "--showOnboarding"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
22 changes: 18 additions & 4 deletions PAWS/PAWSAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import CardinalKit
import FHIR
import FHIRToFirestoreAdapter
import FirebaseAccount
import class FirebaseFirestore.FirestoreSettings
import FirestoreDataStorage
import FirestoreStoragePrefixUserIdAdapter
import HealthKit
import HealthKitDataSource
import HealthKitToFHIRAdapter
import PAWSMockDataStorageProvider
import PAWSSharedContext
import Questionnaires
import Scheduler
import SwiftUI
Expand All @@ -24,8 +26,12 @@ import SwiftUI
class PAWSAppDelegate: CardinalKitAppDelegate {
override var configuration: Configuration {
Configuration(standard: FHIR()) {
if !CommandLine.arguments.contains("--disableFirebase") {
FirebaseAccountConfiguration(emulatorSettings: (host: "localhost", port: 9099))
if !FeatureFlags.disableFirebase {
if FeatureFlags.useFirebaseEmulator {
FirebaseAccountConfiguration(emulatorSettings: (host: "localhost", port: 9099))
} else {
FirebaseAccountConfiguration()
}
firestore
}
if HKHealthStore.isHealthDataAvailable() {
Expand All @@ -38,12 +44,20 @@ class PAWSAppDelegate: CardinalKitAppDelegate {


private var firestore: Firestore<FHIR> {
Firestore(
var firestoreSettings = FirestoreSettings()
if FeatureFlags.useFirebaseEmulator {
let settings = FirestoreSettings()
settings.host = "localhost:8080"
settings.isPersistenceEnabled = false
settings.isSSLEnabled = false
}

return Firestore(
adapter: {
FHIRToFirestoreAdapter()
FirestoreStoragePrefixUserIdAdapter()
},
settings: .emulator
settings: firestoreSettings
)
}

Expand Down
4 changes: 2 additions & 2 deletions PAWS/PAWSAppTestingSetup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ private struct PAWSTestingSetup: ViewModifier {
func body(content: Content) -> some View {
content
.task {
if CommandLine.arguments.contains("--skipOnboarding") {
if FeatureFlags.skipOnboarding {
completedOnboardingFlow = true
}
if CommandLine.arguments.contains("--showOnboarding") {
if FeatureFlags.showOnboarding {
completedOnboardingFlow = false
}
}
Expand Down
26 changes: 13 additions & 13 deletions PAWS/Supporting Files/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>CLIENT_ID</string>
<string>750636343858-kev1gbnfovu771ri9hqlh33kuh6reqcg.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>REVERSED_CLIENT_ID</string>
<string>com.googleusercontent.apps.750636343858-kev1gbnfovu771ri9hqlh33kuh6reqcg</string>
<key>API_KEY</key>
<string>API_KEY</string>
<string>AIzaSyAkafWtgHHisoqURUyyYDW9Oj3gBSUaefQ</string>
<key>GCM_SENDER_ID</key>
<string>GCM_SENDER_ID</string>
<string>750636343858</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>edu.stanford.cs342.2023.paws</string>
<key>PROJECT_ID</key>
<string>cs3422023paws</string>
<string>cs342-2023-paws</string>
<key>STORAGE_BUCKET</key>
<string>STORAGE_BUCKET</string>
<string>cs342-2023-paws.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false/>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false/>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true/>
<true></true>
<key>IS_GCM_ENABLED</key>
<true/>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true/>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:123456789012:ios:1234567890123456789012</string>
<string>1:750636343858:ios:2d29a3cdbe7e71868e122b</string>
</dict>
</plist>
</plist>
3 changes: 2 additions & 1 deletion PAWSModules/Sources/PAWSOnboardingFlow/Consent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Onboarding
import PAWSSharedContext
import SwiftUI


Expand Down Expand Up @@ -42,7 +43,7 @@ struct Consent: View {
consentDocument
},
action: {
if !CommandLine.arguments.contains("--disableFirebase") {
if !FeatureFlags.disableFirebase {
onboardingSteps.append(.accountSetup)
} else {
onboardingSteps.append(.healthKitPermissions)
Expand Down
24 changes: 24 additions & 0 deletions PAWSModules/Sources/PAWSSharedContext/FeatureFlags.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// This source file is part of the CS342 2023 PAWS Team Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//

/// A collection of feature flags for the PAWS app.
public enum FeatureFlags {
/// Skips the onboarding flow to enable easier development of features in the application and to allow UI tests to skip the onboarding flow.
public static let skipOnboarding = CommandLine.arguments.contains("--skipOnboarding")
/// Always show the onboarding when the application is launched. Makes it easy to modify and test the onboarding flow without the need to manually remove the application or reset the simulator.
public static let showOnboarding = CommandLine.arguments.contains("--showOnboarding")
/// Disables the Firebase interactions, including the login/sign-up step and the Firebase Firestore upload.
public static let disableFirebase = CommandLine.arguments.contains("--disableFirebase")
#if targetEnvironment(simulator)
/// Defines if the application should connect to the local firebase emulator. Always set to true when using the iOS simulator.
public static let useFirebaseEmulator = true
#else
/// Defines if the application should connect to the local firebase emulator. Always set to true when using the iOS simulator.
public static let useFirebaseEmulator = CommandLine.arguments.contains("--useFirebaseEmulator")
#endif
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ The application includes the following feature flags that can be configured in t
- ``--skipOnboarding``: Skips the onboarding flow to enable easier development of features in the application and to allow UI tests to skip the onboarding flow.
- ``--showOnboarding``: Always show the onboarding when the application is launched. Makes it easy to modify and test the onboarding flow without the need to manually remove the application or reset the simulator.
- ``--disableFirebase``: Disables the Firebase interactions, including the login/sign-up step and the Firebase Firestore upload.
- ``--useFirebaseEmulator``: Defines if the application should connect to the local firebase emulator. Always set to true when using the iOS simulator.


## Continous Delivery Workflows
Expand Down
12 changes: 11 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ platform :ios do
xcodeproj: "PAWS.xcodeproj"
})
build
upload_to_testflight
commit = last_git_commit
upload_to_testflight(
distribute_external: true,
groups: [
"CS342 2023"
],
submit_beta_review: true,
notify_external_testers: true,
expire_previous_builds: true,
changelog: commit[:message]
)
end
end

0 comments on commit 01a1cd5

Please sign in to comment.