KMP wrapper for tencent mars xlog.
| Platform | π Buildsπ + π¬Testsπ¬ |
|---|---|
JVM 17 | π |
JS (Chrome, Node) | π |
WasmJS (Chrome, Node) | π |
WasmWasi (Node) | π |
Android | π |
iOS | π |
macOS | π |
Windows X64 | π |
Linux X64 | π |
For Android/JS/Linux/Windows, you only need to add gradle dependency, for iOS/macOS you need to add an extra cocoapods dependency.
// add common source set dependency kotlin { sourceSets { val commonMain by getting { dependencies { implementation("com.piasy:kmp-xlog:$version") } } } } // add iOS/macOS cocoapods dependency pod 'kmp_xlog', '~> $version'object Logging { const val LEVEL_DEBUG = 1 const val LEVEL_INFO = 2 const val LEVEL_ERROR = 4 } // Android initialize fun initializeMarsXLog( context: Context, logDir: String, level: Int, namePrefix: String, ) // iOS/macOS/Linux/Windows initialize fun initializeMarsXLog( level: Int, namePrefix: String, ) // JS initialize fun initializeConsoleLog(debugLog: Boolean) // logging object Logging { // if debug log is enabled (level is LEVEL_DEBUG) fun debug(): Boolean // compute log content lazily, only when debug log is enabled fun debug(tag: String, block: () -> String) fun debug(tag: String, content: String) fun info(tag: String, content: String) fun error(tag: String, content: String) }You will need cocoapods. You can use RVM to manage your ruby version, and install gems.
You need to use homebrew to install the following tools:
brew install xcodegen # if you have installed them earlier, you need to remove them at first, # or run brew link --overwrite xcodegenYou may need to restart your system so that Android Studio could use the correct ruby.
If you see "pod install" error when you open the project in Android Studio:
> Task :example:shared:podInstall FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':example:shared:podInstall'. > 'pod install' command failed with code 1. Error message: Please, check that podfile contains following lines in header: source 'https://cdn.cocoapods.org' Please, check that each target depended on shared contains following dependencies:This is because iosApp/Podfile depends on the podspec in ../../kmp-xlog/build/cocoapods/publish/release, so please run ./scripts/build_apple.sh and open/sync again.
Open the project (the repo root dir) in Android studio, and run the example.androidApp target.
cd example/iosApp xcodegen pod install # open iosApp.xcworkspace in Xcode, and run it../gradlew :example:shared:jsBrowserRunInstall deps: zlib1g-dev.
./scripts/build_xlog_linux.sh ./gradlew runKmp_xlogDebugExecutableLinuxX64.\gradlew runKmp_xlogDebugExecutableMingwX64Test in command line:
./scripts/build_apple.sh ./gradlew runKmp_xlogDebugExecutableMacosX64Test in GUI:
cd example/macApp xcodegen pod install # open macApp.xcworkspace in Xcode, and run it.# run on macOS, with Android NDK android-ndk-r23d-canary, # https://ci.android.com/builds/branches/aosp-ndk-release-r23/grid # rename the folder as 23.3.12186248 ./scripts/build_xlog_android.sh # run on macOS ./scripts/build_xlog_apple.sh # run on Linux ./scripts/build_xlog_linux.sh # run on Windows #.\scripts\build_xlog_windows.bat # Windows xlog source is compiled by gradle, # no need to build it manually.Test shared code on Android unit test:
./gradlew :kmp-xlog:testDebugUnitTestThen check reports in kmp-xlog/build/reports/tests/testDebugUnitTest.
Maven central portal credentials and signing configs are set in ~/.gradle/gradle.properties.
# on Windows: need manual release on website .\scripts\publish_windows.bat # on Linux: need manual release on website ./scripts/publish_linux.sh # on macOS: need manual release on website ./scripts/publish_others.sh./scripts/build_apple.sh ./scripts/publish_apple_cocoapods.sh