Skip to content

Commit

Permalink
šŸ”€ļø Merge branch 'ladislas/feature/firebase-static-info-plist' into deā€¦
Browse files Browse the repository at this point in the history
ā€¦velop
  • Loading branch information
ladislas committed Nov 19, 2024
2 parents 1317366 + 0a117c4 commit cb47b8a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>io.leka.apf.app.LekaApp</string>
<string>io.leka.apf.app.LekaApp.beta</string>
<key>PROJECT_ID</key>
<string>leka-app-dev</string>
<key>STORAGE_BUCKET</key>
<string>leka-app-dev.appspot.com</string>
<string>leka-app-dev.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false/>
<key>IS_ANALYTICS_ENABLED</key>
Expand All @@ -25,6 +25,6 @@
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>1:749287588285:ios:0a6b2bbbbad6ff5eff92d4</string>
<string>1:749287588285:ios:61749d0965be13a3ff92d4</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>io.leka.apf.app.LekaApp</string>
<string>io.leka.apf.app.LekaApp.beta</string>
<key>PROJECT_ID</key>
<string>leka-app-testflight</string>
<key>STORAGE_BUCKET</key>
<string>leka-app-testflight.appspot.com</string>
<string>leka-app-testflight.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false/>
<key>IS_ANALYTICS_ENABLED</key>
Expand All @@ -25,6 +25,6 @@
<key>IS_SIGNIN_ENABLED</key>
<true/>
<key>GOOGLE_APP_ID</key>
<string>1:475526070863:ios:2ff136669d4c3b5639203a</string>
<string>1:475526070863:ios:b0a000ff6e20892d39203a</string>
</dict>
</plist>
15 changes: 14 additions & 1 deletion Apps/LekaApp/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ let kLekaApp: App = if Environment.productionBuild.getBoolean(
)
}

let kLekaAppFirebaseInfoPlistPath: ResourceFileElement = if Environment.productionBuild.getBoolean(
default: false
) {
"GoogleFirebase/PROD/GoogleService-Info.plist"
} else if Environment.testflightBuild.getBoolean(
default: false
) {
"GoogleFirebase/TESTFLIGHT/GoogleService-Info.plist"
} else {
"GoogleFirebase/DEV/GoogleService-Info.plist"
}

let project = Project.app(
name: "LekaApp",
version: kLekaApp.version,
Expand All @@ -46,8 +58,9 @@ let project = Project.app(
"bluetooth-central",
"audio",
],
"FirebaseAutomaticScreenReportingEnabled": "NO",
"FirebaseAutomaticScreenReportingEnabled": false,
],
resources: [kLekaAppFirebaseInfoPlistPath],
settings: SettingsDictionary.extendingBase(with: [
"ASSETCATALOG_COMPILER_APPICON_NAME": "\(kLekaApp.appIcon)",
]),
Expand Down
37 changes: 15 additions & 22 deletions Apps/LekaApp/Sources/MainApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,32 @@ import SwiftUI

let log = LogKit.createLoggerFor(app: "LekaApp")

// MARK: - LekaApp

@main
struct LekaApp: App {
// MARK: Lifecycle

init() {
// ? Set GoogleService-Info.plist based on the build configuration
#if PRODUCTION_BUILD
log.warning("PRODUCTION_BUILD")
let googleServiceInfoPlistName = "GoogleServiceInfo+PROD"
#elseif TESTFLIGHT_BUILD
log.warning("TESTFLIGHT_BUILD")
let googleServiceInfoPlistName = "GoogleServiceInfo+TESTFLIGHT"
#elseif DEVELOPER_MODE
log.warning("DEVELOPER_MODE")
let googleServiceInfoPlistName = "GoogleServiceInfo+DEV"
#else
log.warning("NO BUILD CONFIGURATION")
let googleServiceInfoPlistName = "GoogleServiceInfo+NOT_FOUND"
#endif
// MARK: - AppDelegate

class AppDelegate: NSObject, UIApplicationDelegate {
func application(_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool
{
// ? Enable Firebase Analytics DebugView for TestFlight/Developer mode
#if TESTFLIGHT_BUILD || DEVELOPER_MODE
UserDefaults.standard.set(true, forKey: "/google/firebase/debug_mode")
UserDefaults.standard.set(true, forKey: "/google/measurement/debug_mode")
#endif

FirebaseKit.shared.configure(with: googleServiceInfoPlistName)
FirebaseKit.shared.configure()

return true
}
}

// MARK: - LekaApp

@main
struct LekaApp: App {
// MARK: Internal

@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

@Environment(\.colorScheme) var colorScheme

@ObservedObject var styleManager: StyleManager = .shared
Expand Down
17 changes: 2 additions & 15 deletions Modules/FirebaseKit/Sources/FirebaseKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,8 @@ public class FirebaseKit {

public static let shared = FirebaseKit()

public func configure(with plist: String) {
guard let plistPath = Bundle.main.path(forResource: plist, ofType: "plist"),
let options = FirebaseOptions(contentsOfFile: plistPath)
else {
log.critical("\(plist).plist is missing!")
fatalError("\(plist).plist is missing!")
}

log.warning("Firebase: \(plist)")
log.warning("Firebase options: \(options)")

public func configure() {
FirebaseConfiguration.shared.setLoggerLevel(.min)

FirebaseApp.configure(options: options)
FirebaseApp.configure()
}

// MARK: Private
}
3 changes: 2 additions & 1 deletion Tuist/ProjectDescriptionHelpers/Project+App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public extension Project {
deploymentTargets: DeploymentTargets = .iOS("16.6"),
destinations: Destinations = [.iPad, .macWithiPadDesign],
infoPlist: [String: Plist.Value] = [:],
resources: [ResourceFileElement] = [],
settings: SettingsDictionary = [:],
launchArguments: [LaunchArgument] = [],
options: Options = .options(),
Expand All @@ -56,7 +57,7 @@ public extension Project {
deploymentTargets: deploymentTargets,
infoPlist: .extendingDefault(with: InfoPlist.extendingBase(version: version, with: infoPlist)),
sources: ["Sources/**"],
resources: ["Resources/**"],
resources: .resources(["Resources/**"] + resources),
scripts: TargetScript.linters(),
dependencies: dependencies,
settings: .settings(base: .extendingBase(with: settings)),
Expand Down

0 comments on commit cb47b8a

Please sign in to comment.