Skip to content

Commit 5a99a8f

Browse files
committed
Added working fireebase-app project
1 parent 3841083 commit 5a99a8f

File tree

7 files changed

+101
-8
lines changed

7 files changed

+101
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
/.idea/
55
local.properties
66
/**/*.iml
7+
8+
firebase-app/src/iosMain/c_interop/modules/
9+

firebase-app/build.gradle.kts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ kotlin {
5858
sourceSets {
5959
val commonMain by getting {
6060
dependencies {
61-
//implementation(project(":firebase-common"))
61+
implementation(project(":firebase-common"))
6262
}
6363
}
6464
val androidMain by getting {
@@ -73,6 +73,24 @@ kotlin {
7373
dependencies {
7474
}
7575
}
76+
77+
configure(listOf(iosArm64, iosX64)) {
78+
compilations.getByName("main") {
79+
source(sourceSets.get("iosMain"))
80+
val firebasecore by cinterops.creating {
81+
packageName("cocoapods.FirebaseCore")
82+
defFile(file("$projectDir/src/iosMain/c_interop/FirebaseCore.def"))
83+
//includeDirs("$projectDir/../native/Avalon/Pods/FirebaseCore/Firebase/Core/Public")
84+
compilerOpts("-F$projectDir/src/iosMain/c_interop/modules/FirebaseCore-6.0.2")
85+
}
86+
}
87+
}
88+
89+
cocoapods {
90+
summary = ""
91+
homepage = ""
92+
//pod("FirebaseCore", "~> 6.3.1")
93+
}
7694
}
7795
}
7896

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language = Objective-C
2+
modules = FirebaseCore
3+
compilerOpts = -framework FirebaseCore
4+
linkerOpts = -framework FirebaseCore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package dev.teamhub.firebase
2+
3+
actual class FirebaseApp {
4+
actual val name: String
5+
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
6+
actual val options: FirebaseOptions
7+
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
8+
}
9+
10+
/** Returns the default firebase app instance. */
11+
actual val Firebase.app: FirebaseApp
12+
get() = kotlin.TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
13+
14+
actual fun Firebase.app(name: String): FirebaseApp = kotlin.TODO("not implemented")
15+
16+
actual fun Firebase.apps(context: Any?): List<FirebaseApp> = kotlin.TODO("not implemented")
17+
18+
actual fun Firebase.initialize(context: Any?): FirebaseApp? = kotlin.TODO("not implemented")
19+
20+
/** Initializes and returns a FirebaseApp. */
21+
actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = kotlin.TODO("not implemented")
22+
23+
/** Initializes and returns a FirebaseApp. */
24+
actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = kotlin.TODO("not implemented")
25+
26+
actual open class FirebaseException : Exception()
27+
28+
actual class FirebaseNetworkException : FirebaseException()
29+
30+
actual open class FirebaseTooManyRequestsException : FirebaseException()
31+
32+
actual open class FirebaseApiNotAvailableException : FirebaseException()

firebase-common/build.gradle.kts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ kotlin {
4848
}
4949
}
5050

51+
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
52+
kotlinOptions.freeCompilerArgs += listOf(
53+
"-Xuse-experimental=kotlin.Experimental",
54+
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
55+
"-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer"
56+
)
57+
}
58+
5159
sourceSets {
5260
val commonMain by getting {
5361
dependencies {
@@ -74,18 +82,12 @@ kotlin {
7482
}
7583
val iosMain by creating {
7684
dependencies {
85+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.14.0")
7786
}
7887
}
79-
8088
configure(listOf(iosArm64, iosX64)) {
8189
compilations.getByName("main") {
8290
source(sourceSets.get("iosMain"))
83-
val firebasecore by cinterops.creating {
84-
packageName("cocoapods.FirebaseCore")
85-
defFile(file("$projectDir/src/iosMain/c_interop/FirebaseCore.def"))
86-
//includeDirs("$projectDir/../native/Avalon/Pods/FirebaseCore/Firebase/Core/Public")
87-
compilerOpts("-F$projectDir/src/iosMain/c_interop/modules/FirebaseCore-6.0.2")
88-
}
8991
}
9092
}
9193

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.teamhub.firebase
2+
3+
import kotlinx.serialization.CompositeDecoder
4+
import kotlinx.serialization.KSerializer
5+
import kotlinx.serialization.SerialDescriptor
6+
import kotlinx.serialization.StructureKind
7+
8+
actual fun FirebaseDecoder.structureDecoder(desc: SerialDescriptor, vararg typeParams: KSerializer<*>): CompositeDecoder = when(desc.kind as StructureKind) {
9+
StructureKind.CLASS -> (value as Map<*, *>).let { map ->
10+
FirebaseClassDecoder(map.size, { map.containsKey(it) }) { desc, index -> map[desc.getElementName(index)] }
11+
}
12+
StructureKind.LIST -> (value as List<*>).let {
13+
FirebaseCompositeDecoder(it.size) { _, index -> it[index] }
14+
}
15+
StructureKind.MAP -> (value as Map<*, *>).entries.toList().let {
16+
FirebaseCompositeDecoder(it.size) { _, index -> it[index/2].run { if(index % 2 == 0) key else value } }
17+
}
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dev.teamhub.firebase
2+
3+
import kotlinx.serialization.CompositeEncoder
4+
import kotlinx.serialization.KSerializer
5+
import kotlinx.serialization.SerialDescriptor
6+
import kotlinx.serialization.StructureKind
7+
import kotlin.collections.set
8+
9+
actual fun FirebaseEncoder.structureEncoder(desc: SerialDescriptor, vararg typeParams: KSerializer<*>): CompositeEncoder = when(desc.kind as StructureKind) {
10+
StructureKind.LIST -> mutableListOf<Any?>()
11+
.also { value = it }
12+
.let { FirebaseCompositeEncoder(positiveInfinity) { _, index, value -> it.add(index, value) } }
13+
StructureKind.MAP, StructureKind.CLASS -> mutableMapOf<Any?, Any?>()
14+
.also { value = it }
15+
.let { FirebaseCompositeEncoder(positiveInfinity) { _, index, value -> it[desc.getElementName(index)] = value } }
16+
}

0 commit comments

Comments
 (0)