Simple Kotlin Multi-platform Library to Access the Platform Type in a Common Module.
The platform
global property can be accessed to retrieve the current Platform type at runtime:
fun performPlatformDependentAction() =
when (platform) {
is Platform.Jvm -> jvmAction()
is Platform.Android -> androidAction()
is Platform.Ios -> iosAction()
is Platform.Js -> nodeJsAction()
}
Each Platform
instance provides platform specific properties:
androidPlatform.sdkInt
andoridPlatform.versionName
The library is provided through Repsy.io. Checkout
the releases page to get the latest version.
repositories {
maven { url = "https://repo.repsy.io/mvn/chrynan/public" }
}
implementation "com.chrynan.platform:platform-core:VERSION"
More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.
Copyright 2021 chRyNaN
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.