I have problems getting XCode to choose the correc...
# ios
h
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
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
Any suggestion how to do this? And wouldn't that mean, that the production app will also include "dead" simulator code?
r
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
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
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
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
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
I think I have something like this working, thanks
b
"Universal framework"
h
Thanks, I was able to find that as well. Together with the other replies, I found a suitable solution 🙂
👍 1