Skip to content

Commit

Permalink
Merge pull request #52 from yml-org/fix/crash-http-client
Browse files Browse the repository at this point in the history
fix: not found http client definition on Android
  • Loading branch information
osugikoji authored Mar 21, 2023
2 parents 2460302 + 3874c4a commit 63d1cc5
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 63 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
jobs:
publish-maven:
name: Publish to Maven
runs-on: ubuntu-latest
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -31,7 +31,7 @@ jobs:
run: chmod +x gradlew

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

env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repositories {
Then, simply import the dependency to your `build.gradle` dependencies:

```kotlin
implementation("co.yml:ychat:1.1.0")
implementation("co.yml:ychat:1.1.1")
```

Take a look at the Kotlin code snippet below for an example of how to initialize and use one of the supported features:
Expand Down
Binary file removed YChat-1.1.0.zip
Binary file not shown.
Binary file added YChat-1.1.1.zip
Binary file not shown.
16 changes: 6 additions & 10 deletions YChat.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,30 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-x86_64-simulator</string>
<key>LibraryPath</key>
<string>YChat.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>YChat.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file modified YChat.xcframework/ios-arm64/YChat.framework/YChat
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file modified YChat.xcframework/ios-x86_64-simulator/YChat.framework/YChat
Binary file not shown.

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object Dependencies {
const val KTOR_LOGGING = "io.ktor:ktor-client-logging:${Versions.KTOR}"
const val KTOR_ANDROID = "io.ktor:ktor-client-android:${Versions.KTOR}"
const val KTOR_IOS = "io.ktor:ktor-client-ios:${Versions.KTOR}"
const val KTOR_JAVA = "io.ktor:ktor-client-java:${Versions.KTOR}"
const val KTOR_OKHTTP = "io.ktor:ktor-client-okhttp:${Versions.KTOR}"
}

object DI {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/spm-tasks.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tasks.register<Delete>("updateSwiftPackage") {
description = "Updates the Swift package by removing outdated files and running the `createSwiftPackage` task."
doFirst {
rootDir.listFiles { file ->
val iosLibraryName = properties["library.ios.name"]
val iosLibraryName = properties["IOS_NAME"]
val fileName = file.name
if (fileName.startsWith("$iosLibraryName-") && fileName.endsWith(".zip")) {
delete(file)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kotlin.mpp.enableCInteropCommonization=true
# Lib
GROUP=co.yml
POM_ARTIFACT_ID=ychat
VERSION_NAME=1.1.0
VERSION_NAME=1.1.1
IOS_NAME=YChat

# OSS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal final class CompletionViewModel: ObservableObject {
addLoading()
do {
if input.contains("/image ") {
let result = try await imageGenerations.execute(prompt: input)[0].url
let result = try await imageGenerations.execute(prompt: input)[0]
removeLoading()
addAIImage(url: result)
} else {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement {

dependencyResolutionManagement {
repositories {
mavenLocal()
google()
mavenCentral()
}
Expand Down
4 changes: 2 additions & 2 deletions ychat/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ kotlin {
}
val androidMain by getting {
dependencies {
implementation(Dependencies.Network.KTOR_ANDROID)
implementation(Dependencies.Network.KTOR_OKHTTP)
}
}
val androidTest by getting {
Expand Down Expand Up @@ -98,7 +98,7 @@ kotlin {
}
val jvmMain by getting {
dependencies {
implementation(Dependencies.Network.KTOR_JAVA)
implementation(Dependencies.Network.KTOR_OKHTTP)
}
}
val jvmTest by getting {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package co.yml.ychat.di.module

import io.ktor.client.engine.android.Android
import io.ktor.client.engine.okhttp.OkHttp
import org.koin.dsl.module

internal actual fun platformModule() = module {
single { Android.create() }
single { OkHttp.create() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package co.yml.ychat.di.provider

import io.ktor.client.HttpClient
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.request.header
Expand All @@ -14,6 +15,7 @@ import kotlinx.serialization.json.Json
internal object NetworkProvider {

private const val BASE_URL = "api.openai.com"
private const val TIMEOUT_MILLIS = 60000L

fun provideHttpClient(engine: HttpClientEngine, apiKey: String): HttpClient {
return HttpClient(engine) {
Expand All @@ -25,6 +27,11 @@ internal object NetworkProvider {
}
header("Authorization", "Bearer $apiKey")
}
install(HttpTimeout) {
requestTimeoutMillis = TIMEOUT_MILLIS
connectTimeoutMillis = TIMEOUT_MILLIS
socketTimeoutMillis = TIMEOUT_MILLIS
}
install(ContentNegotiation) {
json(
Json {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package co.yml.ychat.di.module

import io.ktor.client.engine.java.Java
import io.ktor.client.engine.okhttp.OkHttp
import org.koin.dsl.module

internal actual fun platformModule() = module {
single { Java.create() }
single { OkHttp.create() }
}

0 comments on commit 63d1cc5

Please sign in to comment.