Hello, I’m trying to create multiplatform project ...
# mvikotlin
a
Hello, I’m trying to create multiplatform project using new kmm plugin, but I have a problem with ios when defining store
Use of unresolved identifier 'DefaultStoreFactory'
Copy code
let store = NotesStoreFactory(DefaultStoreFactory())
here is my build.gradle.kts file from shared module
Copy code
val commonMain by getting {
    dependencies {
        api("com.arkivanov.mvikotlin:mvikotlin:2.0.0-rc3")
        api("com.arkivanov.mvikotlin:mvikotlin-main:2.0.0-rc3")
        api("com.arkivanov.mvikotlin:rx:2.0.0-rc3")
       //other deps
    }
}
Can someone help me to figure out what was the problem ?
a
Hello. Is it compile time or runtime error?
a
compile time
a
Could you please post a full gradle config?
a
sure
a
I’ll try it now
I’ve tried like this but it’s not worked, defaultstorefactory again doesn’t resolved by xcode
Copy code
ios {
    binaries {
        framework {
            baseName = "shared"
            export("com.arkivanov.mvikotlin:mvikotlin:2.0.0-rc3")
            export("com.arkivanov.mvikotlin:mvikotlin-main:2.0.0-rc3")
            export("com.arkivanov.mvikotlin:rx:2.0.0-rc3")
        }
    }
}
maybe I did something wrong here?
a
I think I will need a reproducer project. You can strip out any code you don't want to disclose. Or if it is an open source project, just a link would be good
a
np, that’s my first test project with kmm, so I’ll push it to github and send you link
a
This would be awesome! I could check it later tonight
a
thank you very much 🙌
a
I have submitted a PR fixing the issue: https://github.com/arthur-ghazaryan/test-kmm-app/pull/1
The point is to properly export external dependencies. A suffix with the current target should be added.
a
Thank you very much 👍
👍 1
l
Hi @Arkadii Ivanov thx for the solution. Do you why is this happening or where can I read about it?
a
Hello @lehakorshun I'm not sure if there are any materials about it. I checked manually this particular case and found that nothing from MVIKotlin was exported to Swift. So I searched through GitHub and found how people are exporting external dependencies. Looks like, when exporting such dependencies, compiler is not smart enough to resolve required artifacts. So we need to specify the exact target.
l
also when I try to use this solution I have an issue in compile time
Could not resolve com.arkivanov.mvikotlinmvikotlin iosx642.0.0-rc3
a
also when I try to use this solution I have an issue in compile time
Could please describe what is the issue?
l
when I try to build project with suffixes for export, I have
Could not resolve com.arkivanov.mvikotlinmvikotlin iosx642.0.0-rc3
a
Could you please provide your
build.gradle
file?
also, If I remove suffixes, I can use MvikotlinLifecycle and MvikotlinLifecycle, but I can find MvikotlinLifecycleRegistry like as BaseMviView
looks like compiler export the interfaces only.
a
I'm not sure at the moment. The build file looks correct. Artifacts with the
iosx64
suffix are available. https://dl.bintray.com/arkivanov/maven/com/arkivanov/mvikotlin/mvikotlin-iosx64/2.0.0-rc3/ Unfortunately I don't have much experience with exporting to Swift. This solution supposed to work. Could you please provide a full error output?
What Kotlin version are you using?
l
version - 1.4.0
I think problem is here
Could not determine the dependencies of task ‘afisha sourcelinkDebugFrameworkIosArm64’
link iosx64 in arm task…
a
Could you please provide full build log? Or at least full error output?
Arm64?
l
a
Ok, looks like it incorrectly resolves the target and/or prefix
It comes from Xcode as env variables
l
it was when I tried to execute ./gradlew build
a
I think the problem is in the
getIosTargetName
l
but if I use ./gradlew packForXcode it is success
a
Cause build builds all targets
But there are no env variables from xcode in this case, so it uses same target name every time
l
yes after pack task all dependencies in framework
a
Yep, don't depend build on pack
This task is supposed to be executed from Xcode
l
but I executed it from terminal
a
Env variables are passed by xcode, specially for this case
l
but what is the difference when I execute build task from terminal?
a
A special build phase should be setup in Xcode, so it executes ./gradlew packForXcode and passes the configuration and current architecture
So you choose a build type in Xcode and it passes this info to Gradle
l
right now I dont launch Xcode and pack task works correct, but if I try to execute build task, I have an error
oh sorry, I’m slowing down
a
Yes, this is expected. Since build task builds both targets iosX64 and iosArm64. But there are no env variables from xcode so the
getIosTargetName
returns same name every time, which is
iosX64
l
in build task we try to build x64 and arm and execute pack task 2 times
a
yes
l
@Arkadii Ivanov thx
big thx )
🎉 1