Skip to content

Commit 63d1cc5

Browse files
authored
Merge pull request #52 from yml-org/fix/crash-http-client
fix: not found http client definition on Android
2 parents 2460302 + 3874c4a commit 63d1cc5

File tree

20 files changed

+27
-63
lines changed

20 files changed

+27
-63
lines changed

.github/workflows/publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
jobs:
1212
publish-maven:
1313
name: Publish to Maven
14-
runs-on: ubuntu-latest
14+
runs-on: macos-11
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v3
@@ -31,7 +31,7 @@ jobs:
3131
run: chmod +x gradlew
3232

3333
- name: Publish to Repository
34-
run: ./gradlew :ychat:clean publish
34+
run: ./gradlew clean publish --no-parallel --stacktrace
3535

3636
env:
3737
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ repositories {
5959
Then, simply import the dependency to your `build.gradle` dependencies:
6060

6161
```kotlin
62-
implementation("co.yml:ychat:1.1.0")
62+
implementation("co.yml:ychat:1.1.1")
6363
```
6464

6565
Take a look at the Kotlin code snippet below for an example of how to initialize and use one of the supported features:

YChat-1.1.0.zip

-10.7 MB
Binary file not shown.

YChat-1.1.1.zip

8.55 MB
Binary file not shown.

YChat.xcframework/Info.plist

+6-10
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,30 @@
55
<key>AvailableLibraries</key>
66
<array>
77
<dict>
8-
<key>DebugSymbolsPath</key>
9-
<string>dSYMs</string>
108
<key>LibraryIdentifier</key>
11-
<string>ios-arm64</string>
9+
<string>ios-x86_64-simulator</string>
1210
<key>LibraryPath</key>
1311
<string>YChat.framework</string>
1412
<key>SupportedArchitectures</key>
1513
<array>
16-
<string>arm64</string>
14+
<string>x86_64</string>
1715
</array>
1816
<key>SupportedPlatform</key>
1917
<string>ios</string>
18+
<key>SupportedPlatformVariant</key>
19+
<string>simulator</string>
2020
</dict>
2121
<dict>
22-
<key>DebugSymbolsPath</key>
23-
<string>dSYMs</string>
2422
<key>LibraryIdentifier</key>
25-
<string>ios-x86_64-simulator</string>
23+
<string>ios-arm64</string>
2624
<key>LibraryPath</key>
2725
<string>YChat.framework</string>
2826
<key>SupportedArchitectures</key>
2927
<array>
30-
<string>x86_64</string>
28+
<string>arm64</string>
3129
</array>
3230
<key>SupportedPlatform</key>
3331
<string>ios</string>
34-
<key>SupportedPlatformVariant</key>
35-
<string>simulator</string>
3632
</dict>
3733
</array>
3834
<key>CFBundlePackageType</key>
Binary file not shown.

YChat.xcframework/ios-arm64/dSYMs/YChat.framework.dSYM/Contents/Info.plist

-20
This file was deleted.
Binary file not shown.

YChat.xcframework/ios-x86_64-simulator/dSYMs/YChat.framework.dSYM/Contents/Info.plist

-20
This file was deleted.

buildSrc/src/main/kotlin/Dependencies.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object Dependencies {
3434
const val KTOR_LOGGING = "io.ktor:ktor-client-logging:${Versions.KTOR}"
3535
const val KTOR_ANDROID = "io.ktor:ktor-client-android:${Versions.KTOR}"
3636
const val KTOR_IOS = "io.ktor:ktor-client-ios:${Versions.KTOR}"
37-
const val KTOR_JAVA = "io.ktor:ktor-client-java:${Versions.KTOR}"
37+
const val KTOR_OKHTTP = "io.ktor:ktor-client-okhttp:${Versions.KTOR}"
3838
}
3939

4040
object DI {

buildSrc/src/main/kotlin/spm-tasks.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tasks.register<Delete>("updateSwiftPackage") {
2121
description = "Updates the Swift package by removing outdated files and running the `createSwiftPackage` task."
2222
doFirst {
2323
rootDir.listFiles { file ->
24-
val iosLibraryName = properties["library.ios.name"]
24+
val iosLibraryName = properties["IOS_NAME"]
2525
val fileName = file.name
2626
if (fileName.startsWith("$iosLibraryName-") && fileName.endsWith(".zip")) {
2727
delete(file)

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ kotlin.mpp.enableCInteropCommonization=true
1111
# Lib
1212
GROUP=co.yml
1313
POM_ARTIFACT_ID=ychat
14-
VERSION_NAME=1.1.0
14+
VERSION_NAME=1.1.1
1515
IOS_NAME=YChat
1616

1717
# OSS

sample/ios/YChatApp/Features/Completion/ViewModel/CompletionViewModel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal final class CompletionViewModel: ObservableObject {
4242
addLoading()
4343
do {
4444
if input.contains("/image ") {
45-
let result = try await imageGenerations.execute(prompt: input)[0].url
45+
let result = try await imageGenerations.execute(prompt: input)[0]
4646
removeLoading()
4747
addAIImage(url: result)
4848
} else {

settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pluginManagement {
88

99
dependencyResolutionManagement {
1010
repositories {
11+
mavenLocal()
1112
google()
1213
mavenCentral()
1314
}

ychat/build.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ kotlin {
6767
}
6868
val androidMain by getting {
6969
dependencies {
70-
implementation(Dependencies.Network.KTOR_ANDROID)
70+
implementation(Dependencies.Network.KTOR_OKHTTP)
7171
}
7272
}
7373
val androidTest by getting {
@@ -98,7 +98,7 @@ kotlin {
9898
}
9999
val jvmMain by getting {
100100
dependencies {
101-
implementation(Dependencies.Network.KTOR_JAVA)
101+
implementation(Dependencies.Network.KTOR_OKHTTP)
102102
}
103103
}
104104
val jvmTest by getting {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package co.yml.ychat.di.module
22

3-
import io.ktor.client.engine.android.Android
3+
import io.ktor.client.engine.okhttp.OkHttp
44
import org.koin.dsl.module
55

66
internal actual fun platformModule() = module {
7-
single { Android.create() }
7+
single { OkHttp.create() }
88
}

ychat/src/commonMain/kotlin/co/yml/ychat/di/provider/NetworkProvider.kt

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package co.yml.ychat.di.provider
22

33
import io.ktor.client.HttpClient
44
import io.ktor.client.engine.HttpClientEngine
5+
import io.ktor.client.plugins.HttpTimeout
56
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
67
import io.ktor.client.plugins.defaultRequest
78
import io.ktor.client.request.header
@@ -14,6 +15,7 @@ import kotlinx.serialization.json.Json
1415
internal object NetworkProvider {
1516

1617
private const val BASE_URL = "api.openai.com"
18+
private const val TIMEOUT_MILLIS = 60000L
1719

1820
fun provideHttpClient(engine: HttpClientEngine, apiKey: String): HttpClient {
1921
return HttpClient(engine) {
@@ -25,6 +27,11 @@ internal object NetworkProvider {
2527
}
2628
header("Authorization", "Bearer $apiKey")
2729
}
30+
install(HttpTimeout) {
31+
requestTimeoutMillis = TIMEOUT_MILLIS
32+
connectTimeoutMillis = TIMEOUT_MILLIS
33+
socketTimeoutMillis = TIMEOUT_MILLIS
34+
}
2835
install(ContentNegotiation) {
2936
json(
3037
Json {
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package co.yml.ychat.di.module
22

3-
import io.ktor.client.engine.java.Java
3+
import io.ktor.client.engine.okhttp.OkHttp
44
import org.koin.dsl.module
55

66
internal actual fun platformModule() = module {
7-
single { Java.create() }
7+
single { OkHttp.create() }
88
}

0 commit comments

Comments
 (0)