https://kotlinlang.org logo
Title
a

AG

09/06/2020, 2:56 PM
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'
let store = NotesStoreFactory(DefaultStoreFactory())
here is my build.gradle.kts file from shared module
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

Arkadii Ivanov

09/06/2020, 3:00 PM
Hello. Is it compile time or runtime error?
a

AG

09/06/2020, 3:01 PM
compile time
a

Arkadii Ivanov

09/06/2020, 3:01 PM
Could you please post a full gradle config?
a

AG

09/06/2020, 3:02 PM
sure
a

AG

09/06/2020, 3:12 PM
I’ll try it now
I’ve tried like this but it’s not worked, defaultstorefactory again doesn’t resolved by xcode
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

Arkadii Ivanov

09/06/2020, 3:25 PM
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

AG

09/06/2020, 3:27 PM
np, that’s my first test project with kmm, so I’ll push it to github and send you link
a

Arkadii Ivanov

09/06/2020, 3:27 PM
This would be awesome! I could check it later tonight
a

AG

09/06/2020, 3:35 PM
thank you very much 🙌
a

Arkadii Ivanov

09/06/2020, 8:41 PM
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

AG

09/06/2020, 8:59 PM
Thank you very much 👍
👍 1
l

lehakorshun

09/08/2020, 5:02 PM
Hi @Arkadii Ivanov thx for the solution. Do you why is this happening or where can I read about it?
a

Arkadii Ivanov

09/08/2020, 5:07 PM
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

lehakorshun

09/08/2020, 5:07 PM
also when I try to use this solution I have an issue in compile time
Could not resolve com.arkivanov.mvikotlin:mvikotlin-iosx64:2.0.0-rc3
a

Arkadii Ivanov

09/08/2020, 5:09 PM
also when I try to use this solution I have an issue in compile time
Could please describe what is the issue?
l

lehakorshun

09/08/2020, 5:10 PM
when I try to build project with suffixes for export, I have
Could not resolve com.arkivanov.mvikotlin:mvikotlin-iosx64:2.0.0-rc3
a

Arkadii Ivanov

09/08/2020, 5:11 PM
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

Arkadii Ivanov

09/08/2020, 5:18 PM
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

lehakorshun

09/08/2020, 5:22 PM
version - 1.4.0
I think problem is here
Could not determine the dependencies of task ‘:afisha-source:linkDebugFrameworkIosArm64’
link iosx64 in arm task…
a

Arkadii Ivanov

09/08/2020, 5:24 PM
Could you please provide full build log? Or at least full error output?
Arm64?
l

lehakorshun

09/08/2020, 5:24 PM
a

Arkadii Ivanov

09/08/2020, 5:26 PM
Ok, looks like it incorrectly resolves the target and/or prefix
It comes from Xcode as env variables
l

lehakorshun

09/08/2020, 5:26 PM
it was when I tried to execute ./gradlew build
a

Arkadii Ivanov

09/08/2020, 5:27 PM
I think the problem is in the
getIosTargetName
l

lehakorshun

09/08/2020, 5:27 PM
but if I use ./gradlew packForXcode it is success
a

Arkadii Ivanov

09/08/2020, 5:28 PM
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

lehakorshun

09/08/2020, 5:28 PM
yes after pack task all dependencies in framework
a

Arkadii Ivanov

09/08/2020, 5:29 PM
Yep, don't depend build on pack
This task is supposed to be executed from Xcode
l

lehakorshun

09/08/2020, 5:30 PM
but I executed it from terminal
a

Arkadii Ivanov

09/08/2020, 5:31 PM
Env variables are passed by xcode, specially for this case
l

lehakorshun

09/08/2020, 5:31 PM
but what is the difference when I execute build task from terminal?
a

Arkadii Ivanov

09/08/2020, 5:31 PM
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

lehakorshun

09/08/2020, 5:33 PM
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

Arkadii Ivanov

09/08/2020, 5:35 PM
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

lehakorshun

09/08/2020, 5:35 PM
in build task we try to build x64 and arm and execute pack task 2 times
a

Arkadii Ivanov

09/08/2020, 5:36 PM
yes
l

lehakorshun

09/08/2020, 5:36 PM
@Arkadii Ivanov thx
big thx )
🎉 1