diff --git a/build-logic/src/main/kotlin/main.kt b/build-logic/src/main/kotlin/main.kt index 8ee54bb..994ac8b 100644 --- a/build-logic/src/main/kotlin/main.kt +++ b/build-logic/src/main/kotlin/main.kt @@ -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 { @@ -66,6 +67,8 @@ fun Project.library( configureKMP() configureKotlin() + (extensions.getByName("kotlin") as KotlinMultiplatformExtension).apply(kotlin) + if (moko) { configureMoko(namespace) } diff --git a/gradle.properties b/gradle.properties index e184d04..8ef201b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,3 +8,4 @@ kotlin.code.style=official android.useAndroidX=true systemProp.org.gradle.internal.publish.checksums.insecure=true +moko.resources.disableStaticFrameworkWarning=true \ No newline at end of file diff --git a/sample-app-android/build.gradle.kts b/sample-app-android/build.gradle.kts index f09470e..1725353 100644 --- a/sample-app-android/build.gradle.kts +++ b/sample-app-android/build.gradle.kts @@ -4,7 +4,7 @@ plugins { id("org.jetbrains.compose") } -androidApp("io.openfeedback.android.sample") +androidApp("io.openfeedback.android") android { defaultConfig { diff --git a/sample-app-ios/io.openfeedback.ios.xcodeproj/project.pbxproj b/sample-app-ios/io.openfeedback.ios.xcodeproj/project.pbxproj index db57931..115f86f 100644 --- a/sample-app-ios/io.openfeedback.ios.xcodeproj/project.pbxproj +++ b/sample-app-ios/io.openfeedback.ios.xcodeproj/project.pbxproj @@ -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 */ @@ -21,6 +22,7 @@ 1167ADE12BB0CFED001541D8 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 1167ADE32BB0CFEE001541D8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 1167ADE62BB0CFEE001541D8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 11D241752BB109C900370624 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../Downloads/GoogleService-Info.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -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; @@ -140,6 +143,7 @@ files = ( 1167ADE72BB0CFEE001541D8 /* Preview Assets.xcassets in Resources */, 1167ADE42BB0CFEE001541D8 /* Assets.xcassets in Resources */, + 11D241762BB109C900370624 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -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 */ diff --git a/sample-app-ios/io.openfeedback.ios.xcodeproj/project.xcworkspace/xcuserdata/mbonnin.xcuserdatad/UserInterfaceState.xcuserstate b/sample-app-ios/io.openfeedback.ios.xcodeproj/project.xcworkspace/xcuserdata/mbonnin.xcuserdatad/UserInterfaceState.xcuserstate index 9c8b2ce..03c9b4e 100644 Binary files a/sample-app-ios/io.openfeedback.ios.xcodeproj/project.xcworkspace/xcuserdata/mbonnin.xcuserdatad/UserInterfaceState.xcuserstate and b/sample-app-ios/io.openfeedback.ios.xcodeproj/project.xcworkspace/xcuserdata/mbonnin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/sample-app-ios/io.openfeedback.ios.xcodeproj/xcshareddata/xcschemes/io.openfeedback.ios.xcscheme b/sample-app-ios/io.openfeedback.ios.xcodeproj/xcshareddata/xcschemes/io.openfeedback.ios.xcscheme new file mode 100644 index 0000000..d74dd7d --- /dev/null +++ b/sample-app-ios/io.openfeedback.ios.xcodeproj/xcshareddata/xcschemes/io.openfeedback.ios.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample-app-ios/io.openfeedback.ios.xcodeproj/xcuserdata/mbonnin.xcuserdatad/xcschemes/xcschememanagement.plist b/sample-app-ios/io.openfeedback.ios.xcodeproj/xcuserdata/mbonnin.xcuserdatad/xcschemes/xcschememanagement.plist index cce49e4..b0a8241 100644 --- a/sample-app-ios/io.openfeedback.ios.xcodeproj/xcuserdata/mbonnin.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/sample-app-ios/io.openfeedback.ios.xcodeproj/xcuserdata/mbonnin.xcuserdatad/xcschemes/xcschememanagement.plist @@ -31,5 +31,13 @@ 1 + SuppressBuildableAutocreation + + 1167ADDB2BB0CFED001541D8 + + primary + + + diff --git a/sample-app-ios/io.openfeedback.ios/ContentView.swift b/sample-app-ios/io.openfeedback.ios/ContentView.swift index 65951ce..028489e 100644 --- a/sample-app-ios/io.openfeedback.ios/ContentView.swift +++ b/sample-app-ios/io.openfeedback.ios/ContentView.swift @@ -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) {} diff --git a/sample-app-ios/io.openfeedback.ios/io_openfeedback_iosApp.swift b/sample-app-ios/io.openfeedback.ios/io_openfeedback_iosApp.swift index 0dc932d..3a5d359 100644 --- a/sample-app-ios/io.openfeedback.ios/io_openfeedback_iosApp.swift +++ b/sample-app-ios/io.openfeedback.ios/io_openfeedback_iosApp.swift @@ -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() diff --git a/sample-app-shared/build.gradle.kts b/sample-app-shared/build.gradle.kts index 29660d2..7c74e04 100644 --- a/sample-app-shared/build.gradle.kts +++ b/sample-app-shared/build.gradle.kts @@ -9,13 +9,11 @@ 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 @@ -23,7 +21,9 @@ kotlin { } } } +} +kotlin { sourceSets { getByName("commonMain") { dependencies { diff --git a/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt b/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt index 3cb94fd..a65a0d3 100644 --- a/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt +++ b/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt @@ -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) ) }