Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@
*.xcbkptlist
!/.idea/codeStyles/*
!/.idea/inspectionProfiles/*
.kotlin
.kotlin
ios/Pods
ios/KaMPKitiOS.xcworkspace
36 changes: 36 additions & 0 deletions 2.0_ohos_test_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 1.记录原始url
ORIGIN_DISTRIBUTION_URL=$(grep "distributionUrl" gradle/wrapper/gradle-wrapper.properties | cut -d "=" -f 2)
echo "origin gradle url: $ORIGIN_DISTRIBUTION_URL"
# 2.切换gradle版本
NEW_DISTRIBUTION_URL="https\:\/\/services.gradle.org\/distributions\/gradle-8.0-bin.zip"
sed -i.bak "s/distributionUrl=.*$/distributionUrl=$NEW_DISTRIBUTION_URL/" gradle/wrapper/gradle-wrapper.properties
echo "new gradle url: " $(grep "distributionUrl" gradle/wrapper/gradle-wrapper.properties | cut -d "=" -f 2)

# 3.开始发布
KUIKLY_AGP_VERSION="7.4.2" KUIKLY_KOTLIN_VERSION="2.0.21-KBA-004" ./gradlew -c settings.2.0.ohos.gradle.kts :core-annotations:publishToMavenLocal --stacktrace
KUIKLY_AGP_VERSION="7.4.2" KUIKLY_KOTLIN_VERSION="2.0.21-KBA-004" ./gradlew -c settings.2.0.ohos.gradle.kts :core:publishToMavenLocal --stacktrace
KUIKLY_AGP_VERSION="7.4.2" KUIKLY_KOTLIN_VERSION="2.0.21-KBA-004" ./gradlew -c settings.2.0.ohos.gradle.kts :core-ksp:publishToMavenLocal --stacktrace
KUIKLY_AGP_VERSION="7.4.2" KUIKLY_KOTLIN_VERSION="2.0.21-KBA-004" ./gradlew -c settings.2.0.ohos.gradle.kts :core-render-android:publishToMavenLocal --stacktrace
KUIKLY_AGP_VERSION="7.4.2" KUIKLY_KOTLIN_VERSION="2.0.21-KBA-004" ./gradlew -c settings.2.0.ohos.gradle.kts :compose:publishToMavenLocal --stacktrace
KUIKLY_AGP_VERSION="7.4.2" KUIKLY_KOTLIN_VERSION="2.0.21-KBA-004" ./gradlew -c settings.2.0.ohos.gradle.kts :demo:linkSharedReleaseSharedOhosArm64 --stacktrace


# 4.还原文件
mv gradle/wrapper/gradle-wrapper.properties.bak gradle/wrapper/gradle-wrapper.properties
mv gradle.properties.bak gradle.properties


# 5.拷贝so
echo "Copying artifact files:"
OHOS_RENDER_PROJECT_DIR=./ohosApp

TARGET_SO_PATH=$PWD/demo/build/bin/ohosArm64/sharedReleaseShared/libshared.so
OHO_SO_PROJECT_PATH=$OHOS_RENDER_PROJECT_DIR/entry/libs/arm64-v8a
cp $TARGET_SO_PATH $OHO_SO_PROJECT_PATH
echo "libshared.so: copied from $TARGET_SO_PATH to ohos demo directory: $OHO_SO_PROJECT_PATH"

TARGET_SO_HEADER_PATH=$PWD/demo/build/bin/ohosArm64/sharedReleaseShared/libshared_api.h
OHO_SO_HEADER_PATH=$OHOS_RENDER_PROJECT_DIR/entry/src/main/cpp/thirdparty/biz_entry
cp $TARGET_SO_HEADER_PATH $OHO_SO_HEADER_PATH
echo "libshared_api.h: copied from $TARGET_SO_HEADER_PATH to ohos demo directory: $OHO_SO_HEADER_PATH"
echo "Copy ops done!"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ removed.
Whereas KaMP Kit started with the goal of being a minimal sample, we now intend it to be less "getting started" and
more "best practice model". Watch this repo and follow [@TouchlabHQ](https://twitter.com/TouchlabHQ) for updates!

### 2026 Update
Supported Ohos
![KaMP Kit Image](docs/ohos.jpg)

### 2023 Update

We updated `KaMPKit` to make sure of Touchlab's new [SKIE](https://skie.touchlab.co/) tool. SKIE allowed use to remove a lot of boilerplate code related to `ViewModel` sharing, and also we can now use Kotlin sealed classes as Swift enums in iOS code. Take a look at our detailed [migration case study](https://touchlabpro.touchlab.dev/touchlab/training/skie-architecture/migrating-kampkit-to-skie)
Expand Down
20 changes: 20 additions & 0 deletions build.2.0.ohos.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
kotlin("multiplatform") version "2.0.21-KBA-004" apply false
kotlin("plugin.compose") version "2.0.21-KBA-004" apply false
id("com.android.application") version "7.4.2" apply false
id("com.android.library") version "7.4.2" apply false
id("org.jetbrains.compose") version "1.7.3" apply false
id("com.google.devtools.ksp") version "2.0.21-1.0.27" apply false
}

allprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
jvmTargetValidationMode.set(org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode.WARNING)
}
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("${MavenConfig.GROUP}:core")).using(project(":core"))
substitute(module("${MavenConfig.GROUP}:core-annotations")).using(project(":core-annotations"))
}
}
}
7 changes: 7 additions & 0 deletions build.kampkit.ohos.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* KaMPKit root build for OHOS (KBA Kotlin 2.0.21).
* Minimal — only declares plugin versions; actual config is in shared/build.2.0.ohos.gradle.kts.
*/
plugins {
kotlin("multiplatform") version "2.0.21-KBA-004" apply false
}
Binary file added docs/ohos.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-ios = { module = "io.ktor:ktor-client-ios", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-client-okHttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-client-js = { module = "io.ktor:ktor-client-js", version.ref = "ktor" }
ktor-client-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ktor-client-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion ios/KaMPKitiOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\ncd \"$SRCROOT/..\"\n./gradlew embedAndSignAppleFrameworkForXcode\n";
shellScript = "if [ \"YES\" = \"$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED\" ]; then\n echo \"Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \\\"YES\\\"\"\n exit 0\nfi\n# Type a script or drag a script file from your workspace to insert its path.\ncd \"$SRCROOT/..\"\n./gradlew embedAndSignAppleFrameworkForXcode";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
62 changes: 32 additions & 30 deletions ios/KaMPKitiOS/BreedListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,43 @@ struct BreedRowView: View {
Button(action: onTap) {
HStack {
Text(breed.name)
.foregroundColor(.black)
.padding(4.0)
Spacer()
Image(systemName: (!breed.favorite) ? "heart" : "heart.fill")
.foregroundColor(.black)
.padding(4.0)
}
}
}
}

struct BreedListScreen_Previews: PreviewProvider {
static var previews: some View {
Group {
BreedListContent(
state: .Content(breeds: [
Breed(id: 0, name: "appenzeller", favorite: false),
Breed(id: 1, name: "australian", favorite: true)
]),
onBreedFavorite: { _ in },
refresh: {}
)
BreedListContent(
state: .Initial.shared,
onBreedFavorite: { _ in },
refresh: {}
)
BreedListContent(
state: .Empty(),
onBreedFavorite: { _ in },
refresh: {}
)
BreedListContent(
state: .Error(error: "Something went wrong!"),
onBreedFavorite: { _ in },
refresh: {}
)
}
}
}
//
//struct BreedListScreen_Previews: PreviewProvider {
// static var previews: some View {
// Group {
// BreedListContent(
// state: .Content(breeds: [
// Breed(id: 0, name: "appenzeller", favorite: false),
// Breed(id: 1, name: "australian", favorite: true)
// ]),
// onBreedFavorite: { _ in },
// refresh: {}
// )
// BreedListContent(
// state: .Initial.shared,
// onBreedFavorite: { _ in },
// refresh: {}
// )
// BreedListContent(
// state: .Empty(),
// onBreedFavorite: { _ in },
// refresh: {}
// )
// BreedListContent(
// state: .Error(error: "Something went wrong!"),
// onBreedFavorite: { _ in },
// refresh: {}
// )
// }
// }
//}
14 changes: 14 additions & 0 deletions ohos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/node_modules
/oh_modules
/local.properties
/.idea
entry/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test
/.appanalyzer
/entry/libs/arm64-v8a/libshared.so
/entry/src/main/cpp/thirdparty/biz_entry/libshared_api.h
Empty file added ohos/.ohpmrc
Empty file.
10 changes: 10 additions & 0 deletions ohos/AppScope/app.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"app": {
"bundleName": "com.tencent.kuiklyohosapp",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
8 changes: 8 additions & 0 deletions ohos/AppScope/resources/base/element/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "KaMPKit"
}
]
}
Binary file added ohos/AppScope/resources/base/media/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions ohos/build-profile.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"app": {
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "/Users/lory/.ohos/config/default_ohos_8NfQlnT5rns4SZCXIqn1LgbZK1UsYfGYI0JnUlXQ5oE=.cer",
"keyAlias": "debugKey",
"keyPassword": "0000001B4E5E8146BFA5436885037192DA650E2D54E5903B168621B8457BE088DBD641BE49AB5AEB289E44",
"profile": "/Users/lory/.ohos/config/default_ohos_8NfQlnT5rns4SZCXIqn1LgbZK1UsYfGYI0JnUlXQ5oE=.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "/Users/lory/.ohos/config/default_ohos_8NfQlnT5rns4SZCXIqn1LgbZK1UsYfGYI0JnUlXQ5oE=.p12",
"storePassword": "0000001B2CAD1755A9EFE7FEE585B7597E768E05788636AAC286AB2D41548E799D8DC661CEEAFD1A19C00A"
}
}
],
"products": [
{
"name": "default",
"signingConfig": "default",
"compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS",
}
],
"buildModeSet": [
{
"name": "debug",
},
{
"name": "release"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
Loading