Skip to content

Added crashlytics #358

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 8 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Firebase*.zip

/**/nativeInterop/cinterop/Cartfile.resolved
/**/nativeInterop/cinterop/Carthage/
/kotlin-js-store/yarn.lock
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar

The following libraries are available for the various Firebase products.

| Service or Product | Gradle Dependency | API Coverage |
|---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.7.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.7.0/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.7.0/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.7.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.7.0/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.7.0/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.7.0/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.7.0/pom) | ![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square) |
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.7.0/pom) | ![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square) |
| Service or Product | Gradle Dependency | API Coverage |
|---------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.7.1/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.7.1/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.7.1/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.7.1/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.7.1/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.7.1/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.7.1/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.7.1/pom) | ![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square) |
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.7.1/pom) | ![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square) |
| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.7.1`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.7.1/pom) | ![80%](https://img.shields.io/badge/-1%25-orange?style=flat-square) |



Expand Down Expand Up @@ -202,15 +203,16 @@ If you are building a Kotlin multiplatform library which will be consumed from J

```json
"dependencies": {
"@gitlive/firebase-auth": "1.7.0",
"@gitlive/firebase-config": "1.7.0",
"@gitlive/firebase-database": "1.7.0",
"@gitlive/firebase-firestore": "1.7.0",
"@gitlive/firebase-functions": "1.7.0",
"@gitlive/firebase-installations": "1.7.0",
"@gitlive/firebase-messaging": "1.7.0",
"@gitlive/firebase-storage": "1.7.0"
"@gitlive/firebase-perf": "1.7.0"
"@gitlive/firebase-auth": "1.7.1",
"@gitlive/firebase-config": "1.7.1",
"@gitlive/firebase-database": "1.7.1",
"@gitlive/firebase-firestore": "1.7.1",
"@gitlive/firebase-functions": "1.7.1",
"@gitlive/firebase-installations": "1.7.1",
"@gitlive/firebase-messaging": "1.7.1",
"@gitlive/firebase-storage": "1.7.1"
"@gitlive/firebase-perf": "1.7.1"
"@gitlive/firebase-crashlytics": "1.7.1"
}
```

Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ subprojects {
"commonTestImplementation"(kotlin("test-common"))
"commonTestImplementation"(kotlin("test-annotations-common"))
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1-native-mt")
"jsTestImplementation"(kotlin("test-js"))
if (this@afterEvaluate.name != "firebase-crashlytics") {
"jsTestImplementation"(kotlin("test-js"))
}
"androidAndroidTestImplementation"(kotlin("test-junit"))
"androidAndroidTestImplementation"("junit:junit:4.13.2")
"androidAndroidTestImplementation"("androidx.test:core:1.4.0")
Expand Down
4 changes: 2 additions & 2 deletions firebase-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-app",
"version": "1.7.0",
"version": "1.7.1",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-app.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-common": "1.7.0",
"@gitlive/firebase-common": "1.7.1",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-auth",
"version": "1.7.0",
"version": "1.7.1",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-auth.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.0",
"@gitlive/firebase-app": "1.7.1",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
2 changes: 1 addition & 1 deletion firebase-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-common",
"version": "1.7.0",
"version": "1.7.1",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-common.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions firebase-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-config",
"version": "1.7.0",
"version": "1.7.1",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-config.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.0",
"@gitlive/firebase-app": "1.7.1",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
153 changes: 153 additions & 0 deletions firebase-crashlytics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.KonanTarget

version = project.property("firebase-crashlytics.version") as String

plugins {
id("com.android.library")
kotlin("multiplatform")
}

android {
compileSdk = property("targetSdkVersion") as Int
defaultConfig {
minSdk = property("minSdkVersion") as Int
targetSdk = property("targetSdkVersion") as Int
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
sourceSets {
getByName("main") {
manifest.srcFile("src/androidMain/AndroidManifest.xml")
}
getByName("androidTest"){
java.srcDir(file("src/androidAndroidTest/kotlin"))
manifest.srcFile("src/androidAndroidTest/AndroidManifest.xml")
}
}
testOptions {
unitTests.apply {
isIncludeAndroidResources = true
}
}
packagingOptions {
resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module")
resources.pickFirsts.add("META-INF/AL2.0")
resources.pickFirsts.add("META-INF/LGPL2.1")
}
lint {
abortOnError = false
}
}

val KonanTarget.archVariant: String
get() = if (this is KonanTarget.IOS_X64 || this is KonanTarget.IOS_SIMULATOR_ARM64) {
"ios-arm64_i386_x86_64-simulator"
} else {
"ios-arm64_armv7"
}

kotlin {

android {
publishAllLibraryVariants()
}

val supportIosTarget = project.property("skipIosTarget") != "true"
if (supportIosTarget) {

fun nativeTargetConfig(): KotlinNativeTarget.() -> Unit = {
val nativeFrameworkPaths = listOf(
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/iOS")
).plus(
listOf(
"FirebaseAnalytics",
"FirebaseCore",
"FirebaseCoreDiagnostics",
"FirebaseInstallations",
"GoogleAppMeasurement",
"GoogleAppMeasurementIdentitySupport",
"GoogleDataTransport",
"GoogleUtilities",
"nanopb",
"PromisesObjC"
).map {
rootProject.project("firebase-app").projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/$it.xcframework/${konanTarget.archVariant}")
}
).plus(
listOf(
"FirebaseCrashlytics"
).map {
projectDir.resolve("src/nativeInterop/cinterop/Carthage/Build/$it.xcframework/${konanTarget.archVariant}")
}
)
binaries {
getTest("DEBUG").apply {
linkerOpts(nativeFrameworkPaths.map { "-F$it" })
linkerOpts("-ObjC")
}
}

compilations.getByName("main") {
cinterops.create("FirebaseCrashlytics") {
compilerOpts(nativeFrameworkPaths.map { "-F$it" })
extraOpts = listOf("-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=", "-verbose")
}
}
}

ios(configure = nativeTargetConfig())
iosSimulatorArm64(configure = nativeTargetConfig())
}

sourceSets {
all {
languageSettings.apply {
apiVersion = "1.6"
languageVersion = "1.6"
progressiveMode = true
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}

val commonMain by getting {
dependencies {
api(project(":firebase-app"))
implementation(project(":firebase-common"))
}
}

val androidMain by getting {
dependencies {
api("com.google.firebase:firebase-crashlytics")
}
}

if (supportIosTarget) {
val iosMain by getting
val iosSimulatorArm64Main by getting
iosSimulatorArm64Main.dependsOn(iosMain)

val iosTest by sourceSets.getting
val iosSimulatorArm64Test by sourceSets.getting
iosSimulatorArm64Test.dependsOn(iosTest)
}
}
}

if (project.property("firebase-crashlytics.skipIosTests") == "true") {
tasks.forEach {
if (it.name.contains("ios", true) && it.name.contains("test", true)) { it.enabled = false }
}
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
31 changes: 31 additions & 0 deletions firebase-crashlytics/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@gitlive/firebase-crashlytics",
"version": "1.7.1",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-crashlytics.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/GitLiveApp/firebase-kotlin-sdk.git"
},
"keywords": [
"kotlin",
"multiplatform",
"kotlin-js",
"firebase"
],
"author": "dev.gitlive",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/GitLiveApp/firebase-kotlin-sdk/issues"
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.1",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.gitlive.firebase.crashlytics">

<application android:usesCleartextTraffic="true" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
*/

@file:JvmName("tests")
package dev.gitlive.firebase.crashlytics

import androidx.test.platform.app.InstrumentationRegistry
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking

actual val emulatorHost: String = "10.0.2.2"

actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext

actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="com.crashlytics.android.build_id">1</string>
</resources>
1 change: 1 addition & 0 deletions firebase-crashlytics/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="dev.gitlive.firebase.crashlytics"/>
Loading