https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
z

zsperske

08/26/2020, 7:21 PM
Does anyone have experience with compiling their KMP app into an iOS archive to upload to TestFlight? I packaged my shared code as a framework and included it in my iPhone target but when I try to build an archive for a Generic iOS Device, I end up getting a
No such module 'SharedCode'
error on my import statements
k

kpgalligan

08/26/2020, 7:46 PM
You need to make sure you’ve got both
iosArm64
and
iosX64
targets in your config
Copy code
val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
if (onPhone) {
    iosArm64("ios")
} else {
    iosX64("ios")
}
You can also do that with just
ios
but we had issues in older intellij builds
z

zsperske

08/26/2020, 7:48 PM
I was using this from the jetbrains tutorial
Copy code
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            ::iosArm64
        else
            ::iosX64 
    iOSTarget("ios") {
        binaries {
            framework {
                baseName = "SharedCode"
            }
        }
    }
I also tried forcing it to only do arm. In your example you don't specify the shared module, is that handled elsewhere?
k

kpgalligan

08/26/2020, 7:49 PM
Cocoapods
The JB tutorial doesn’t use cocoapods
z

zsperske

08/26/2020, 7:50 PM
ahhh yeah I remember asking you about that
should I be going the cocoapod route as well?
k

kpgalligan

08/26/2020, 7:50 PM
That’s up to you. I’ve had non-cocoapods work in an Archive. I don’t know what you’d need to do to fix it, but it can work.
I find cocoapods easier with simpler projects, but it can get complex.
👍 1
z

zsperske

08/26/2020, 7:52 PM
will keep at it, thanks!
r

russhwolf

08/26/2020, 7:52 PM
The new project templates in 1.4 aren't bad for a non-cocoapods reference. Lot of improvement there compared to the old stuff
z

zsperske

08/26/2020, 7:54 PM
IDE templates? or somewhere under https://github.com/Kotlin ?
r

russhwolf

08/26/2020, 7:54 PM
IDE
though it won't answer your testflight-specific questions probably
z

zsperske

08/26/2020, 7:55 PM
still, worth a look. i've put off updating to 1.4 since when I took a look last week a lot of artifacts still weren't available
y

yousefa2

08/26/2020, 8:00 PM
Definitely worth updating to 1.4. It will simplify handling deivce/simulator part so you won’t have to worry about it. The statement
No such module 'SharedCode'
implies that it’s not finding the framework that’s being built by gradle. If I assume correctly then you would probably have a build phase to run
./gradlew packForXcode
to build the framework and if this is passing then the problem might be in Xcode rather than gradle. The only thing I can think of is search paths. Make sure they have the root folder where the framework is being created.
👍 1
z

zsperske

08/26/2020, 8:02 PM
sounds like i know what I'm doing this afternoon. thanks all! I love this slack group so much.
🙌 1
2 Views