Skip to content

Commit

Permalink
fix Firebase init
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Mar 25, 2024
1 parent 1692c7b commit 6855591
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 14 deletions.
5 changes: 4 additions & 1 deletion build-logic/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ fun Project.configureMoko(namespace: String) {
fun Project.library(
namespace: String,
artifactName: String?,
moko: Boolean = false
moko: Boolean = false,
kotlin: KotlinMultiplatformExtension.() -> Unit = {}
) {
if (artifactName != null) {
extensions.getByType(OpenFeedback::class.java).apply {
Expand All @@ -66,6 +67,8 @@ fun Project.library(
configureKMP()
configureKotlin()

(extensions.getByName("kotlin") as KotlinMultiplatformExtension).apply(kotlin)

if (moko) {
configureMoko(namespace)
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ kotlin.code.style=official
android.useAndroidX=true

systemProp.org.gradle.internal.publish.checksums.insecure=true
moko.resources.disableStaticFrameworkWarning=true
2 changes: 1 addition & 1 deletion sample-app-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id("org.jetbrains.compose")
}

androidApp("io.openfeedback.android.sample")
androidApp("io.openfeedback.android")

android {
defaultConfig {
Expand Down
6 changes: 5 additions & 1 deletion sample-app-ios/io.openfeedback.ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1167ADE72BB0CFEE001541D8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1167ADE62BB0CFEE001541D8 /* Preview Assets.xcassets */; };
11D2416F2BB0D96D00370624 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 11D2416E2BB0D96D00370624 /* FirebaseAuth */; };
11D241712BB0D96D00370624 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 11D241702BB0D96D00370624 /* FirebaseFirestore */; };
11D241762BB109C900370624 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 11D241752BB109C900370624 /* GoogleService-Info.plist */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -21,6 +22,7 @@
1167ADE12BB0CFED001541D8 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
1167ADE32BB0CFEE001541D8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1167ADE62BB0CFEE001541D8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
11D241752BB109C900370624 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../Downloads/GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -58,6 +60,7 @@
1167ADDF2BB0CFED001541D8 /* io_openfeedback_iosApp.swift */,
1167ADE12BB0CFED001541D8 /* ContentView.swift */,
1167ADE32BB0CFEE001541D8 /* Assets.xcassets */,
11D241752BB109C900370624 /* GoogleService-Info.plist */,
1167ADE52BB0CFEE001541D8 /* Preview Content */,
);
path = io.openfeedback.ios;
Expand Down Expand Up @@ -140,6 +143,7 @@
files = (
1167ADE72BB0CFEE001541D8 /* Preview Assets.xcassets in Resources */,
1167ADE42BB0CFEE001541D8 /* Assets.xcassets in Resources */,
11D241762BB109C900370624 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -178,7 +182,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"$SRCROOT/../gradlew\" -p \"$SRCROOT/../\" :sample-app-shared:copyFrameworkResourcesToApp \\\n -Pmoko.resources.BUILT_PRODUCTS_DIR=$BUILT_PRODUCTS_DIR \\\n -Pmoko.resources.CONTENTS_FOLDER_PATH=$CONTENTS_FOLDER_PATH\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"$SRCROOT/../gradlew\" -p \"$SRCROOT/../\" :sample-app-shared:copyFrameworkResourcesToApp \\\n -Pmoko.resources.PLATFORM_NAME=\"$PLATFORM_NAME\" \\\n -Pmoko.resources.CONFIGURATION=\"$CONFIGURATION\" \\\n -Pmoko.resources.ARCHS=\"$ARCHS\" \\\n -Pmoko.resources.BUILT_PRODUCTS_DIR=\"$BUILT_PRODUCTS_DIR\" \\\n -Pmoko.resources.CONTENTS_FOLDER_PATH=\"$CONTENTS_FOLDER_PATH\"\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1167ADDB2BB0CFED001541D8"
BuildableName = "io.openfeedback.ios.app"
BlueprintName = "io.openfeedback.ios"
ReferencedContainer = "container:io.openfeedback.ios.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1167ADDB2BB0CFED001541D8"
BuildableName = "io.openfeedback.ios.app"
BlueprintName = "io.openfeedback.ios"
ReferencedContainer = "container:io.openfeedback.ios.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "IDEPreferLogStreaming"
value = "YES"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1167ADDB2BB0CFED001541D8"
BuildableName = "io.openfeedback.ios.app"
BlueprintName = "io.openfeedback.ios"
ReferencedContainer = "container:io.openfeedback.ios.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,13 @@
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>1167ADDB2BB0CFED001541D8</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
6 changes: 5 additions & 1 deletion sample-app-ios/io.openfeedback.ios/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import SwiftUI
import UIKit
import SwiftUI
import SampleApp
import FirebaseCore

struct ComposeView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
MainViewControllerKt.MainViewController()
// let options = FirebaseOptions(googleAppID: "1:635903227116:web:31de912f8bf29befb1e1c9", gcmSenderID: "lknlkn")
// FirebaseApp.configure(options: options)
//
return MainViewControllerKt.MainViewController()
}

func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
Expand Down
12 changes: 12 additions & 0 deletions sample-app-ios/io.openfeedback.ios/io_openfeedback_iosApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@
//

import SwiftUI
import FirebaseCore

class AppDelegate: NSObject, UIApplicationDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}
}

@main
struct io_openfeedback_iosApp: App {

@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

var body: some Scene {
WindowGroup {
ContentView()
Expand Down
14 changes: 7 additions & 7 deletions sample-app-shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ plugins {
library(
namespace = "io.openfeedback.shared",
artifactName = null,
moko = true
)

kotlin {
targets.configureEach {
if (this is KotlinNativeTarget) {
binaries {
moko = true,
) {
targets.forEach {
if (it is KotlinNativeTarget) {
it.binaries {
this.framework {
baseName = "SampleApp"
isStatic = true
}
}
}
}
}

kotlin {
sourceSets {
getByName("commonMain") {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,26 @@ fun SampleApp(
ThemeSwitcher(isLight = isLight) { isLight = it }
}
item {
/**
* The firebase parameters are from the openfeedback.io project so we can
* access firestore directly
*/
val openFeedbackFirebaseConfig = OpenFeedbackFirebaseConfig(
context = context,
projectId = "open-feedback-42",
applicationId = "1:635903227116:web:31de912f8bf29befb1e1c9",
// Hack: I replaced :web: by :ios: for the iOS SDK to behave
applicationId = "1:635903227116:ios:31de912f8bf29befb1e1c9",
apiKey = "AIzaSyB3ELJsaiItrln0uDGSuuHE1CfOJO67Hb4",
databaseUrl = "https://open-feedback-42.firebaseio.com/"
)
/**
* The project and session Ids are taken from openfeedback.io demo conference:
* https://openfeedback.io/eaJnyMXD3oNfhrrnBYDT/
*/
OpenFeedback(
config = openFeedbackFirebaseConfig,
projectId = "x957vfwwtWxn8wF6RSLb",
sessionId = "KWhBK2ysHnazBasuU7s0",
projectId = "eaJnyMXD3oNfhrrnBYDT",
sessionId = "100",
modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp)
)
}
Expand Down

0 comments on commit 6855591

Please sign in to comment.