From 15fc9080c6f940a08f4e5c76e475addabff88306 Mon Sep 17 00:00:00 2001 From: Victor Mykhailiv Date: Fri, 1 Sep 2023 09:30:47 +0200 Subject: [PATCH] Publish core & koin to GitHub packages --- LICENSE.txt | 2 +- README.md | 61 +++++++++++++- androidApp/build.gradle.kts | 7 +- .../com/vitoksmile/kmp/health/MainActivity.kt | 4 +- .../src/androidMain/res/values/strings.xml | 2 +- core/HealthKMP.podspec | 39 +++++++++ core/build.gradle.kts | 46 ++++++---- .../health/HealthConnectPermissionActivity.kt | 4 +- core/src/androidMain/kotlin/main.android.kt | 5 -- core/src/iosMain/kotlin/main.ios.kt | 7 -- iosApp/Configuration/Config.xcconfig | 2 +- iosApp/Podfile | 1 + iosApp/iosApp.xcodeproj/project.pbxproj | 6 +- iosApp/iosApp/ContentView.swift | 9 +- koin/HealthKMPKoin.podspec | 39 +++++++++ koin/build.gradle.kts | 35 ++++++-- .../kmp/health/koin/HealthKMPKoin.kt | 14 ++++ koin/src/iosMain/kotlin/health.kmp.koin.kt | 10 --- sample/HealthKMPSample.podspec | 39 +++++++++ sample/build.gradle.kts | 83 +++++++++++++++++++ .../kmp/health/sample/AndroidPlatform.kt | 3 + .../vitoksmile/kmp/health/sample/SampleApp.kt | 4 +- .../kmp/health/sample/HealthKMPSample.kt | 10 +++ .../kmp/health/sample/iOSPlatform.kt | 5 ++ settings.gradle.kts | 10 +++ 25 files changed, 388 insertions(+), 59 deletions(-) create mode 100644 core/HealthKMP.podspec delete mode 100644 core/src/androidMain/kotlin/main.android.kt delete mode 100644 core/src/iosMain/kotlin/main.ios.kt create mode 100644 koin/HealthKMPKoin.podspec create mode 100644 koin/src/iosMain/kotlin/com/vitoksmile/kmp/health/koin/HealthKMPKoin.kt delete mode 100644 koin/src/iosMain/kotlin/health.kmp.koin.kt create mode 100644 sample/HealthKMPSample.podspec create mode 100644 sample/build.gradle.kts create mode 100644 sample/src/androidMain/kotlin/com/vitoksmile/kmp/health/sample/AndroidPlatform.kt rename core/src/commonMain/kotlin/App.kt => sample/src/commonMain/kotlin/com/vitoksmile/kmp/health/sample/SampleApp.kt (98%) create mode 100644 sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/HealthKMPSample.kt create mode 100644 sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/iOSPlatform.kt diff --git a/LICENSE.txt b/LICENSE.txt index 244380c..22ff8b0 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2020-2021 JetBrains s.r.o. and and respective authors and developers. + Copyright 2023 Viktor Mykhailiv Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index fd456fc..7d2341b 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,63 @@ Note that for Android, the target phone **needs** to have ~~[Google Fit](https:/ ## Data Types - STEPS -- WEIGHT \ No newline at end of file +- WEIGHT + + +# Using + +You need an access token to install GitHub packages, see [Managing your personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens). + +local.properties +``` +GITHUB_USERNAME=email@email.com +GITHUB_TOKEN=xxx +``` + +settings.gradle.kts: +```kotlin +dependencyResolutionManagement { + repositories { + maven { + url = uri("https://maven.pkg.github.com/vitoksmile/HealthKMP") + name = "GitHubPackages" + credentials { + val properties = java.util.Properties() + properties.load(file("local.properties").inputStream()) + username = properties["GITHUB_USERNAME"].toString() + password = properties["GITHUB_TOKEN"].toString() + } + } + } +} +``` + +build.gradle: +```kotlin +sourceSets { + val commonMain by getting { + dependencies { + implementation("com.vitoksmile.health-kmp:core:0.0.1") + } + } +} +``` + +If you are using Koin, add to build.gradle: +```kotlin +implementation("com.vitoksmile.health-kmp:koin:0.0.1") +``` + + +## 👷 Project Structure +* core - module with main source for the HealthKMP library +* koin - module with extensions for Koin + +* sample - shared code for sample Compose project +* androidApp - sample Android projects that use HealthKMP +* iosApp - sample iOS projects that use HealthKMP + + +## 📜 License + +This project is licensed under the Apache License, Version 2.0 - see the [LICENSE.md](https://github.com/Foso/Ktorfit/blob/master/LICENSE) file for details \ No newline at end of file diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 79eed90..24b8a8b 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UNUSED_VARIABLE") + plugins { kotlin("multiplatform") id("com.android.application") @@ -9,8 +11,9 @@ kotlin { sourceSets { val androidMain by getting { dependencies { - implementation(project(":core")) - implementation(project(":koin")) + implementation("com.vitoksmile.health-kmp:core:0.0.1") + implementation("com.vitoksmile.health-kmp:koin:0.0.1") + implementation(project(":sample")) } } } diff --git a/androidApp/src/androidMain/kotlin/com/vitoksmile/kmp/health/MainActivity.kt b/androidApp/src/androidMain/kotlin/com/vitoksmile/kmp/health/MainActivity.kt index 32113ac..afcacaf 100644 --- a/androidApp/src/androidMain/kotlin/com/vitoksmile/kmp/health/MainActivity.kt +++ b/androidApp/src/androidMain/kotlin/com/vitoksmile/kmp/health/MainActivity.kt @@ -1,16 +1,16 @@ package com.vitoksmile.kmp.health -import MainView import android.os.Bundle import androidx.activity.compose.setContent import androidx.appcompat.app.AppCompatActivity +import com.vitoksmile.kmp.health.sample.SampleApp class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - MainView() + SampleApp() } } } \ No newline at end of file diff --git a/androidApp/src/androidMain/res/values/strings.xml b/androidApp/src/androidMain/res/values/strings.xml index cdc7544..a23c2ee 100644 --- a/androidApp/src/androidMain/res/values/strings.xml +++ b/androidApp/src/androidMain/res/values/strings.xml @@ -1,3 +1,3 @@ - HealthKMP + Health \ No newline at end of file diff --git a/core/HealthKMP.podspec b/core/HealthKMP.podspec new file mode 100644 index 0000000..3cdb84b --- /dev/null +++ b/core/HealthKMP.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'HealthKMP' + spec.version = '0.0.1' + spec.homepage = 'https://github.com/vitoksmile/HealthKMP' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Wrapper for HealthKit on iOS and Google Fit and Health Connect on Android.' + spec.vendored_frameworks = 'build/cocoapods/framework/HealthKMP.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14.1' + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':core', + 'PRODUCT_MODULE_NAME' => 'HealthKMP', + } + + spec.script_phases = [ + { + :name => 'Build HealthKMP', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 23c901c..9c5f75e 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,14 +1,37 @@ @file:Suppress("UNUSED_VARIABLE") +import java.util.Properties + plugins { kotlin("multiplatform") kotlin("native.cocoapods") id("com.android.library") - id("org.jetbrains.compose") + id("maven-publish") +} + +group = "com.vitoksmile.health-kmp" +version = "0.0.1" + +publishing { + repositories { + maven { + url = uri("https://maven.pkg.github.com/vitoksmile/HealthKMP") + name = "GitHubPackages" + credentials { + val properties = Properties() + properties.load(project.rootProject.file("local.properties").inputStream()) + username = properties["GITHUB_USERNAME"].toString() + password = properties["GITHUB_TOKEN"].toString() + } + } + } } kotlin { - androidTarget() + androidTarget { + publishLibraryVariants("release", "debug") + publishLibraryVariantsGroupedByFlavor = true + } iosX64() iosArm64() @@ -30,23 +53,13 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) - - // Fix ios build - implementation("org.jetbrains.kotlinx:atomicfu:0.21.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") } } val androidMain by getting { dependencies { - api("androidx.activity:activity-compose:1.7.2") - api("androidx.appcompat:appcompat:1.6.1") - api("androidx.core:core-ktx:1.10.1") - + implementation("androidx.activity:activity:1.7.2") implementation("androidx.startup:startup-runtime:1.1.1") implementation("androidx.health.connect:connect-client:1.1.0-alpha03") @@ -61,6 +74,11 @@ kotlin { iosX64Main.dependsOn(this) iosArm64Main.dependsOn(this) iosSimulatorArm64Main.dependsOn(this) + + dependencies { + // Fix ios build + implementation("org.jetbrains.kotlinx:atomicfu:0.21.0") + } } } } diff --git a/core/src/androidMain/kotlin/com/vitoksmile/kmp/health/HealthConnectPermissionActivity.kt b/core/src/androidMain/kotlin/com/vitoksmile/kmp/health/HealthConnectPermissionActivity.kt index bee36bf..d9afbd6 100644 --- a/core/src/androidMain/kotlin/com/vitoksmile/kmp/health/HealthConnectPermissionActivity.kt +++ b/core/src/androidMain/kotlin/com/vitoksmile/kmp/health/HealthConnectPermissionActivity.kt @@ -3,7 +3,7 @@ package com.vitoksmile.kmp.health import android.content.Context import android.content.Intent import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity +import androidx.activity.ComponentActivity import androidx.health.connect.client.PermissionController import kotlin.coroutines.resume import kotlinx.coroutines.CancellableContinuation @@ -14,7 +14,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine * * https://issuetracker.google.com/issues/233239418 */ -internal class HealthConnectPermissionActivity : AppCompatActivity() { +internal class HealthConnectPermissionActivity : ComponentActivity() { companion object { private const val KEY_READ_PERMISSIONS = "KEY_READ_PERMISSIONS" diff --git a/core/src/androidMain/kotlin/main.android.kt b/core/src/androidMain/kotlin/main.android.kt deleted file mode 100644 index d5723a2..0000000 --- a/core/src/androidMain/kotlin/main.android.kt +++ /dev/null @@ -1,5 +0,0 @@ -import androidx.compose.runtime.Composable - -actual fun getPlatformName(): String = "Android" - -@Composable fun MainView() = App() diff --git a/core/src/iosMain/kotlin/main.ios.kt b/core/src/iosMain/kotlin/main.ios.kt deleted file mode 100644 index 2b49b42..0000000 --- a/core/src/iosMain/kotlin/main.ios.kt +++ /dev/null @@ -1,7 +0,0 @@ -@file:Suppress("unused", "FunctionName") - -import androidx.compose.ui.window.ComposeUIViewController - -actual fun getPlatformName(): String = "iOS" - -fun MainViewController() = ComposeUIViewController { App() } \ No newline at end of file diff --git a/iosApp/Configuration/Config.xcconfig b/iosApp/Configuration/Config.xcconfig index 8808449..bf3c27b 100644 --- a/iosApp/Configuration/Config.xcconfig +++ b/iosApp/Configuration/Config.xcconfig @@ -1,3 +1,3 @@ TEAM_ID= BUNDLE_ID=com.vitoksmile.kmp.health -APP_NAME=HealthKMP +APP_NAME=Health diff --git a/iosApp/Podfile b/iosApp/Podfile index c822e7e..6978cac 100644 --- a/iosApp/Podfile +++ b/iosApp/Podfile @@ -3,4 +3,5 @@ target 'iosApp' do platform :ios, '14.1' pod 'HealthKMP', :path => '../core' pod 'HealthKMPKoin', :path => '../koin' + pod 'HealthKMPSample', :path => '../sample' end \ No newline at end of file diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index 8413f51..e43ccfb 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -20,7 +20,7 @@ 20ACF4E2201EBCFD0F637C2A /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; 68E4587840B67DF8CD73E3AE /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; }; - 7555FF7B242A565900829871 /* HealthKMP.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HealthKMP.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 7555FF7B242A565900829871 /* Health.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Health.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9429AFAC2A68240500E5B251 /* iosApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iosApp.entitlements; sourceTree = ""; }; @@ -70,7 +70,7 @@ 7555FF7C242A565900829871 /* Products */ = { isa = PBXGroup; children = ( - 7555FF7B242A565900829871 /* HealthKMP.app */, + 7555FF7B242A565900829871 /* Health.app */, ); name = Products; sourceTree = ""; @@ -123,7 +123,7 @@ ); name = iosApp; productName = iosApp; - productReference = 7555FF7B242A565900829871 /* HealthKMP.app */; + productReference = 7555FF7B242A565900829871 /* Health.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ diff --git a/iosApp/iosApp/ContentView.swift b/iosApp/iosApp/ContentView.swift index 96d968c..64f6a7b 100644 --- a/iosApp/iosApp/ContentView.swift +++ b/iosApp/iosApp/ContentView.swift @@ -1,16 +1,17 @@ import UIKit import SwiftUI -import core -import koin +import HealthKMP +import HealthKMPKoin +import HealthKMPSample struct ComposeView: UIViewControllerRepresentable { init() { - Health_kmp_koinKt.start() + HealthKMPKoin().start() } func makeUIViewController(context: Context) -> UIViewController { - Main_iosKt.MainViewController() + HealthKMPSample().MainViewController() } func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} diff --git a/koin/HealthKMPKoin.podspec b/koin/HealthKMPKoin.podspec new file mode 100644 index 0000000..9ea1817 --- /dev/null +++ b/koin/HealthKMPKoin.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'HealthKMPKoin' + spec.version = '0.0.1' + spec.homepage = 'https://github.com/vitoksmile/HealthKMP' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Shared Koin module for wrapper for HealthKit on iOS and Google Fit and Health Connect on Android.' + spec.vendored_frameworks = 'build/cocoapods/framework/HealthKMPKoin.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14.1' + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':koin', + 'PRODUCT_MODULE_NAME' => 'HealthKMPKoin', + } + + spec.script_phases = [ + { + :name => 'Build HealthKMPKoin', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/koin/build.gradle.kts b/koin/build.gradle.kts index 46b6774..21be4a1 100644 --- a/koin/build.gradle.kts +++ b/koin/build.gradle.kts @@ -1,16 +1,40 @@ -@file:Suppress("UNUSED_VARIABLE") +@file:Suppress("UNUSED_VARIABLE", "PropertyName") + +import java.util.Properties plugins { kotlin("multiplatform") kotlin("native.cocoapods") id("com.android.library") + id("maven-publish") +} + +group = "com.vitoksmile.health-kmp" +version = "0.0.1" + +publishing { + repositories { + maven { + url = uri("https://maven.pkg.github.com/vitoksmile/HealthKMP") + name = "GitHubPackages" + credentials { + val properties = Properties() + properties.load(project.rootProject.file("local.properties").inputStream()) + username = properties["GITHUB_USERNAME"].toString() + password = properties["GITHUB_TOKEN"].toString() + } + } + } } @OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class) kotlin { targetHierarchy.default() - androidTarget() + androidTarget { + publishLibraryVariants("release", "debug") + publishLibraryVariantsGroupedByFlavor = true + } iosX64() iosArm64() @@ -19,7 +43,8 @@ kotlin { cocoapods { name = "HealthKMPKoin" version = "0.0.1" - summary = "Shared Koin module for wrapper for HealthKit on iOS and Google Fit and Health Connect on Android." + summary = + "Shared Koin module for wrapper for HealthKit on iOS and Google Fit and Health Connect on Android." homepage = "https://github.com/vitoksmile/HealthKMP" ios.deploymentTarget = "14.1" podfile = project.file("../iosApp/Podfile") @@ -28,11 +53,11 @@ kotlin { isStatic = true } } - + sourceSets { val commonMain by getting { dependencies { - implementation(project(":core")) + implementation("com.vitoksmile.health-kmp:core:0.0.1") api("io.insert-koin:koin-core:3.4.0") } diff --git a/koin/src/iosMain/kotlin/com/vitoksmile/kmp/health/koin/HealthKMPKoin.kt b/koin/src/iosMain/kotlin/com/vitoksmile/kmp/health/koin/HealthKMPKoin.kt new file mode 100644 index 0000000..fb4571b --- /dev/null +++ b/koin/src/iosMain/kotlin/com/vitoksmile/kmp/health/koin/HealthKMPKoin.kt @@ -0,0 +1,14 @@ +@file:Suppress("unused") + +package com.vitoksmile.kmp.health.koin + +import org.koin.core.context.startKoin + +object HealthKMPKoin { + + fun start() { + startKoin { + modules(commonModule()) + } + } +} \ No newline at end of file diff --git a/koin/src/iosMain/kotlin/health.kmp.koin.kt b/koin/src/iosMain/kotlin/health.kmp.koin.kt deleted file mode 100644 index dec883d..0000000 --- a/koin/src/iosMain/kotlin/health.kmp.koin.kt +++ /dev/null @@ -1,10 +0,0 @@ -@file:Suppress("unused") - -import com.vitoksmile.kmp.health.koin.commonModule -import org.koin.core.context.startKoin - -fun start() { - startKoin { - modules(commonModule()) - } -} \ No newline at end of file diff --git a/sample/HealthKMPSample.podspec b/sample/HealthKMPSample.podspec new file mode 100644 index 0000000..9d8c7f0 --- /dev/null +++ b/sample/HealthKMPSample.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'HealthKMPSample' + spec.version = '0.0.1' + spec.homepage = 'https://github.com/vitoksmile/HealthKMP' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Wrapper for HealthKit on iOS and Google Fit and Health Connect on Android.' + spec.vendored_frameworks = 'build/cocoapods/framework/HealthKMPSample.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14.1' + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':sample', + 'PRODUCT_MODULE_NAME' => 'HealthKMPSample', + } + + spec.script_phases = [ + { + :name => 'Build HealthKMPSample', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts new file mode 100644 index 0000000..5ebc2d3 --- /dev/null +++ b/sample/build.gradle.kts @@ -0,0 +1,83 @@ +@file:Suppress("UNUSED_VARIABLE") + +plugins { + kotlin("multiplatform") + kotlin("native.cocoapods") + id("com.android.library") + id("org.jetbrains.compose") +} + +kotlin { + androidTarget() + + iosX64() + iosArm64() + iosSimulatorArm64() + + cocoapods { + name = "HealthKMPSample" + version = "0.0.1" + summary = "Wrapper for HealthKit on iOS and Google Fit and Health Connect on Android." + homepage = "https://github.com/vitoksmile/HealthKMP" + ios.deploymentTarget = "14.1" + podfile = project.file("../iosApp/Podfile") + framework { + baseName = "HealthKMPSample" + isStatic = true + } + } + + sourceSets { + val commonMain by getting { + dependencies { + implementation("com.vitoksmile.health-kmp:core:0.0.1") + + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material) + @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) + implementation(compose.components.resources) + } + } + + val androidMain by getting { + dependencies { + } + } + + val iosX64Main by getting + val iosArm64Main by getting + val iosSimulatorArm64Main by getting + val iosMain by creating { + dependsOn(commonMain) + iosX64Main.dependsOn(this) + iosArm64Main.dependsOn(this) + iosSimulatorArm64Main.dependsOn(this) + + dependencies { + // Fix ios build + implementation("org.jetbrains.kotlinx:atomicfu:0.21.0") + } + } + } +} + +android { + compileSdk = (findProperty("android.compileSdk") as String).toInt() + namespace = "com.vitoksmile.kmp.health.sample" + + sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") + sourceSets["main"].res.srcDirs("src/androidMain/res") + + defaultConfig { + minSdk = (findProperty("android.minSdk") as String).toInt() + targetSdk = (findProperty("android.targetSdk") as String).toInt() + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlin { + jvmToolchain(17) + } +} diff --git a/sample/src/androidMain/kotlin/com/vitoksmile/kmp/health/sample/AndroidPlatform.kt b/sample/src/androidMain/kotlin/com/vitoksmile/kmp/health/sample/AndroidPlatform.kt new file mode 100644 index 0000000..3348f61 --- /dev/null +++ b/sample/src/androidMain/kotlin/com/vitoksmile/kmp/health/sample/AndroidPlatform.kt @@ -0,0 +1,3 @@ +package com.vitoksmile.kmp.health.sample + +actual fun getPlatformName(): String = "Android" \ No newline at end of file diff --git a/core/src/commonMain/kotlin/App.kt b/sample/src/commonMain/kotlin/com/vitoksmile/kmp/health/sample/SampleApp.kt similarity index 98% rename from core/src/commonMain/kotlin/App.kt rename to sample/src/commonMain/kotlin/com/vitoksmile/kmp/health/sample/SampleApp.kt index b120a1b..a8a6a62 100644 --- a/core/src/commonMain/kotlin/App.kt +++ b/sample/src/commonMain/kotlin/com/vitoksmile/kmp/health/sample/SampleApp.kt @@ -1,3 +1,5 @@ +package com.vitoksmile.kmp.health.sample + import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize @@ -21,7 +23,7 @@ import com.vitoksmile.kmp.health.HealthManagerFactory import kotlinx.coroutines.launch @Composable -fun App() { +fun SampleApp() { val coroutineScope = rememberCoroutineScope() val healthManager = remember { HealthManagerFactory().createManager() } diff --git a/sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/HealthKMPSample.kt b/sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/HealthKMPSample.kt new file mode 100644 index 0000000..cf47cea --- /dev/null +++ b/sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/HealthKMPSample.kt @@ -0,0 +1,10 @@ +@file:Suppress("unused", "FunctionName") + +package com.vitoksmile.kmp.health.sample + +import androidx.compose.ui.window.ComposeUIViewController + +object HealthKMPSample { + + fun MainViewController() = ComposeUIViewController { SampleApp() } +} \ No newline at end of file diff --git a/sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/iOSPlatform.kt b/sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/iOSPlatform.kt new file mode 100644 index 0000000..b327419 --- /dev/null +++ b/sample/src/iosMain/kotlin/com/vitoksmile/kmp/health/sample/iOSPlatform.kt @@ -0,0 +1,5 @@ +@file:Suppress("unused", "FunctionName") + +package com.vitoksmile.kmp.health.sample + +actual fun getPlatformName(): String = "iOS" \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index f6895e4..511f70b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,6 +3,7 @@ rootProject.name = "HealthKMP" include(":androidApp") include(":core") include(":koin") +include(":sample") pluginManagement { repositories { @@ -33,5 +34,14 @@ dependencyResolutionManagement { google() mavenCentral() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + maven { + url = uri("https://maven.pkg.github.com/vitoksmile/HealthKMP") + credentials { + val properties = java.util.Properties() + properties.load(file("local.properties").inputStream()) + username = properties["GITHUB_USERNAME"].toString() + password = properties["GITHUB_TOKEN"].toString() + } + } } }