moko-crash-reporting
0.4.0indexedLibrary facilitates reporting fatal and non-fatal exceptions from shared code. Integrates with FirebaseCrashlytics for logging and uses Napier logger for detailed error messages.
Library facilitates reporting fatal and non-fatal exceptions from shared code. Integrates with FirebaseCrashlytics for logging and uses Napier logger for detailed error messages.
This is a Kotlin MultiPlatform library that provides reporting fatal and non-fatal exceptions from common code.
root build.gradle
allprojects {
repositories {
mavenCentral()
}
}
project build.gradle
dependencies {
commonMainImplementation("dev.icerock.moko:crash-reporting-crashlytics:0.4.0") // for CrashlyticsLogger
commonMainImplementation("dev.icerock.moko:crash-reporting-napier:0.4.0") // for CrashReportingAntilog
}
For CrashlyticsLogger need to add FirebaseCrashlytics cocoapod
With mobile-multiplatform-gradle-plugin cocoapods configuration simplest:
build.gradle.kts:
cocoaPods {
podsProject = file("ios-app/Pods/Pods.xcodeproj")
pod("MCRCDynamicProxy", onlyLink = true)
}
project Podfile
pod 'MCRCDynamicProxy', :git => 'https://github.com/icerockdev/moko-crash-reporting.git', :tag => 'release/0.4.0'
pod 'MCRCStaticReporter', :git => 'https://github.com/icerockdev/moko-crash-reporting.git', :tag => 'release/0.4.0'
On iOS side add to AppDelegate:
import FirebaseCore
import MCRCStaticReporter
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.: ] ) -> {
.configure()
.setup()
}
If you haven't already, add Firebase to your project, you can see how to do it here
val logger = CrashlyticsLogger()
// setting user id in crashlytics
logger.setUserId("User_1")
// setting custom key-value in crashlytics
logger.setCustomValue("customValue", "customKey")
// log message in crashlytics
logger.log("Hello World")
// send non-fatal exception to crashlytics
try {
"test".toInt()
} catch (e: NumberFormatException) {
logger.recordException(e)
}
val logger = CrashlyticsLogger() // CrashlyticsLogger for example, you can use any ExceptionLogger implementation
// initialize napier
Napier.base(antilog = CrashReportingAntilog(exceptionLogger = logger))
// All messages will be logged by exceptionLogger
Napier.d(message = "Hello World")
Napier.i(message = "This is random message", tag = )
Napier.w(message = , tag = )
Napier.v(message = , tag = )
{
.toInt()
} (e: NumberFormatException) {
Napier.e(message = , tag = , throwable = e)
}
Please see more examples in the sample directory.
All development (both new features and bug fixes) is performed in the develop branch. This way master always contains the sources of the most recently released version. Please send PRs with bug fixes to the develop branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in master.
The develop branch is pushed to master on release.
For more details on contributing please see the contributing guide.
Copyright 2020 IceRock MAG Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
Surfaced from shared tags and platforms — no rankings paid for.