Christian Sousa
07/13/2020, 11:16 AMSergey Melyukov
07/13/2020, 1:52 PMcom.foo.bar
I want to create another multiplatform project with some examples of using com.foo.bar
How can I add com.foo.bar
as a local dependency for my demo-project?Sergey Melyukov
07/13/2020, 1:56 PMcom.foo.bar
within com.foo.bar
project to not to create a separate repo with examples?Jim
07/14/2020, 4:14 AMype mismatch: inferred type is String but Action<KaptExtension> was expected
I've tried moving kapt (and the associated moshi deps) between jvm and common with no success
has anyone seen kapt working in multiplatform? I attached my build.gradle.kts file and would appreciate any help!audax
07/14/2020, 7:31 AMLoboda Deni
07/14/2020, 11:33 AMLuka
07/14/2020, 1:47 PMI get "Unresolved reference: NativeSqliteDriver" when trying to use it in my ios KMP target (from SQLDelight library). "AndroidSqliteDriver" from my android target resolves normally. Gradle syncs without errors. Any idea how to debug this?
wuseal
07/14/2020, 2:33 PMChintan Soni
07/14/2020, 5:23 PMLoginViewModel
from its method login
.
LoginViewModel.kt:
@ExperimentalCoroutinesApi
class LoginViewModel(private val loginViewState: LoginViewState, private val loginService: LoginService) {
private val _apiStateFlow = MutableStateFlow(loginViewState)
val stateFlow: StateFlow<LoginViewState> = _apiStateFlow
private val _EMAIL_REGEX = "^[A-Za-z](.*)([@]{1})(.{1,})(\\.)(.{1,})"
suspend fun login(email: String, password: String) {
if (isFormValid(email, password)) {
_apiStateFlow.value = loginViewState.copy(isLoginApiLoading = true)
runCatching {
loginService.login(email, password)
}.onSuccess {
loginViewState.copy(isLoginApiLoading = false, loginResponse = it)
}.onFailure {
loginViewState.copy(isLoginApiLoading = false, errorResponse = ErrorResponse(it.message.orEmpty()))
}
}
}
fun isFormValid(email: String, password: String): Boolean {
val isEmailValid = email.isEmailValid()
val isPasswordValid = password.isPasswordValid()
_apiStateFlow.value = loginViewState.copy(isValidEmail = isEmailValid, isValidPassword = isPasswordValid)
return isEmailValid && isPasswordValid
}
private fun String.isEmailValid() = _EMAIL_REGEX.toRegex().matches(this)
private fun String.isPasswordValid() = length in 6..14
}
data class LoginViewState(
val email: String = "",
val password: String = "",
val isValidEmail: Boolean = false,
val isValidPassword: Boolean = false,
val isLoginApiLoading: Boolean = false,
val loginResponse: LoginResponse? = null,
val errorResponse: ErrorResponse? = null
)
Service.kt:
expect val platformEngine: HttpClientEngineFactory<HttpClientEngineConfig>
val myHttpClient: HttpClient
get() = HttpClient(platformEngine) {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
install(Logging) {
level = LogLevel.ALL
}
expectSuccess = false
HttpResponseValidator {
validateResponse { response: HttpResponse ->
println("Response: $response")
val statusCode = response.status.value
when (statusCode) {
in 300..399 -> throw RedirectResponseException(response)
in 400..499 -> throw ClientRequestException(response)
in 500..599 -> throw ServerResponseException(response)
}
if (statusCode >= 600) {
throw ResponseException(response)
}
}
handleResponseException { cause: Throwable ->
println("Exception: $cause")
}
}
defaultRequest {
url {
host = "127.0.0.1:8080/"
protocol = URLProtocol.HTTP
}
timeout {
connectTimeoutMillis = 10000
requestTimeoutMillis = 10000
socketTimeoutMillis = 10000
}
}
}
LoginService.kt:
class LoginService(private val httpClient: HttpClient) {
suspend fun login(email : String, password : String): LoginResponse = <http://httpClient.post|httpClient.post> {
body = LoginRequest(email, password)
}
}
LoginReqRes.kt:
data class LoginRequest(val email: String = "", val password: String = "")
data class LoginResponse(val name: String = "", val age: Int = 0, val email: String = "")
data class ErrorResponse(val message: String)
Any suggestions?jean
07/14/2020, 7:35 PMChintan Soni
07/15/2020, 4:16 AMjs(IR) {
moduleName = "JsDomain"
nodejs {
testTask {
useMocha {
timeout = "10000"
}
}
}
browser {
testTask {
useMocha {
timeout = "10000"
}
}
}
}
aleksey.tomin
07/15/2020, 5:42 AMmacosX64
and linuxX64
and on macos building both. But I want to build only macos targetwillyrs
07/15/2020, 10:28 AMmacosX64("mac") {
binaries {
framework("mac")
}
}
but when I try to import the framework it says:
/Users/*/Projects/RTE/apod-kampkit/ios/ApodKMP.xcodeproj Building for Mac Catalyst, but the linked and embedded framework 'mac.framework' was built for macOS. You may need to restrict the platforms for which this framework should be linked and embedded in the target editor, or replace it with an XCFramework that supports both platforms.
I’m a bit confused since it clearly says that the framework is (correctly?) built for macOS.
I’ve also tried to put this framework in a normal macOS app project and it workszsperske
07/15/2020, 3:17 PMinterface Database {
suspend fun updateEntry(foo: Foo) : Boolean
}
In order to implement this on iOS one option appears to be implementing a kotlin class in my iosMain that could use obj-c interop to achieve what I want. Is it also possible to feed a swift class that I've written (with obj-c headers) into my common code? Are there drawbacks to that?Loboda Deni
07/16/2020, 5:51 AMLoboda Deni
07/16/2020, 6:11 AMjean
07/16/2020, 7:47 AMjvm("android")
for targeting android but I’m reading in the doc that one could also use android { ... }
.
Is the android
shortcut useful only to be able to configure build variants, dependencies, etc… ? The doc says also id("com.android.library")
is necessary but gradle can’t resolve it
Plugin [id: 'com.android.library'] was not found in any of the following sources:
(and then nothing, it does not say any sources).
What if I want to target android and desktop through the jvm? should I just use jvm()
?Luka
07/16/2020, 11:52 AMMichal Janos
07/18/2020, 4:25 PMklock
to multiplatform?
I have implemented 1.11.13, everything works fine, with using npm link
,
but it is not possible to publish it to my private nexus NPM repo
what I try, is to change package.json, and change it to my scope before publish, this help me with kotlin-source-map-loader
,
but klock
create require('klock-root-klock')
on end of generated js file
kotlin multiplatform 1.3.72Kurt Renzo Acosta
07/18/2020, 5:32 PMallTests
? It's just running iosTest
whenever I run it.bod
07/18/2020, 9:06 PMAttila Blenesi
07/20/2020, 3:50 PMKroppeb
07/20/2020, 9:13 PMKroppeb
07/20/2020, 10:22 PMgetResult():T
. Normally in kotlin I can then use value.result
to get this value. However this doesn't seem to be possible with `expect`/`actual`. Am I missing something?oshai
07/21/2020, 6:17 AMChristian Sousa
07/21/2020, 9:59 AMsavrov
07/21/2020, 9:58 PMcommonTest
. Is it possible to access to this class from *B*’s commonTest
?
I thought to do something like this, but it does not seems to work:
commonMain {
dependencies {
implementation(project(':moduleA'))
}
}
commonTest {
dependencies {
implementation(project(':moduleA'))
}
}
aleksey.tomin
07/22/2020, 11:24 AMgetnameinfo
function for macosX64 and linuxX64 target in platform.posix
but for mingwX64 in platform.windows
?
It it a bug or feature?Andrea Prearo
07/22/2020, 4:26 PMDarren Bell
07/22/2020, 8:49 PMkotlin {
js {
useCommonJs()
browser {
binaries.executable()
webpackTask {
cssSupport.enabled = true
devServer = KotlinWebpackConfig.DevServer(true, false, true, true, false, 3000, null, listOf("$projectDir/src/jsMain/resources"))
}
runTask {
cssSupport.enabled = true
}
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
when I run jsBrowserDevelopmentWebpack
I can see the changes have taking in the generated webpack.config.js. However, when I run jsBrowserDevelopmentRun
the configuration seems to get overwritten again. Is anyone having success is this area? Im using the latest 1.4-M3