KMP wrapper for tencent mars xlog.
For Android/JS/Linux/Windows, you only need to add gradle dependency, for iOS/macOS you need 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,
logToConsole: Boolean
)
// iOS/macOS/Linux/Windows initialize
fun initializeMarsXLog(
level: Int,
namePrefix: String,
logToConsole: Boolean
)
// JS initialize
fun initializeConsoleLog()
// logging
object Logging {
fun debug(tag: String, content: String)
fun info(tag: String, content: String)
fun error(tag: String, content: String)
}
You need install RVM to manage your ruby version, and install gems. You need use homebrew to install the following tools:
brew install cocoapods xcodegen
# if you have installed them earlier, you need remove them at first,
# or run brew link --overwrite xcodegen cocoapods
You 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:
Please run ./scripts/build_apple.sh
then open/sync again.
Open the project (the repo root dir) in Android studio, and run the example.androidApp target.
cd example/iosApp
pod install
# open iosApp.xcworkspace in Xcode, and run it.
./gradlew :example:shared:jsBrowserRun
Install deps: zlib1g-dev
.
./scripts/build_xlog_linux.sh
./gradlew runKmp_xlogDebugExecutableLinuxX64
.\gradlew runKmp_xlogDebugExecutableMingwX64
./scripts/build_apple.sh
./gradlew runKmp_xlogDebugExecutableMacosX64
# run on macOS, with Android NDK android-ndk-r23d-canary,
# https://ci.android.com/builds/branches/aosp-ndk-release-r23/grid
./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
Test shared code on Android unit test:
./gradlew :kmp-xlog:testDebugUnitTest
Then 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
.\script\publish_windows.bat
# on Linux: need manual release on website
./script/publish_linux.sh
# on macOS: need manual release on website
./script/publish_others.sh
./build_apple.sh
./publish_apple_cocoapods.sh