https://kotlinlang.org logo
#ios
Title
# ios
h

Henrik

02/04/2020, 8:04 AM
I have problems getting XCode to choose the correct platform (Amr64/X64) for my Kotlin Native library. Following some different guides, I have done this: 1. Added my framework as embedded library. Here I choose either the X64 or Arm64 "debugFramework" folder, since there is no "general" headers generated 2. Added two different framework search paths, one for "Any iOS Simulator" and one for "Any iOS SDK", pointing to X64 or Arm64 respectively It seems no matter what I do, it will build and launch using whatever architecture I set in #1, regardless if I run on the simulator or a real device, and ignore #2, so I need to re-add the entire framework in Xcode when switching between simulator and device. Suggestions?
r

Romain Dubreucq

02/04/2020, 8:26 AM
Hello, why don’t you generate a fat binary framework with the two architectures? You won’t have to choose your binary when targeting real device or simulator.
h

Henrik

02/04/2020, 8:28 AM
Any suggestion how to do this? And wouldn't that mean, that the production app will also include "dead" simulator code?
r

Romain Dubreucq

02/04/2020, 8:29 AM
You can generate your fat binary using the ios Kotlin Native target in your build.gradle file
For your production app, you can add a build phase (for Release build) that deletes the x86_64 architecture from your binary framework when archiving
h

Henrik

02/04/2020, 8:33 AM
Do you have a link to an example of all this? Right now my gradle build is nice and simple:
ios('ios') {
binaries {
framework {
baseName = 'myframework'
}
}
}
r

Romain Dubreucq

02/04/2020, 8:44 AM
Seems good to me. I’m not a Gradle project expert, but I don’t think that you need to specify ios name for your target. Did you check if your binary contains all the architectures with lipo?
h

Henrik

02/04/2020, 8:51 AM
the binaries are built into build/bin/iosArm64 and build/bin/iosX64 - so I assumed they are not combined. I am looking at other gradle examples right now
r

Romain Dubreucq

02/04/2020, 8:54 AM
My bad, I forgot that they were separated 😕 then you should create a script that builds and merge the frameworks architectures into a fat file
h

Henrik

02/04/2020, 9:55 AM
I think I have something like this working, thanks
b

basher

02/04/2020, 1:41 PM
"Universal framework"
h

Henrik

02/04/2020, 1:59 PM
Thanks, I was able to find that as well. Together with the other replies, I found a suitable solution 🙂
👍 1
4 Views