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

manijshrestha

12/13/2018, 5:03 PM
Hey Guys, can someone help me to know if it is possible to build a iOS framework that targets multiple architecture at once? e.g.
Copy code
targets {
        fromPreset(presets.jvm, 'jvm')
        // This preset is for iPhone emulator
        // Switch here to presets.iosArm64 to build library for iPhone device
        fromPreset(presets.iosX64, 'ios') {
            compilations.main.outputKinds('FRAMEWORK')
        }
    }
This would only build x64 and have to switch to Arm 64. It would be ideal if I could have a framework with both so that I can use it for both simulator and real device.
d

dany

12/13/2018, 5:05 PM
you could bundle both into an universal framework
r

russhwolf

12/13/2018, 5:11 PM
You can use this pattern to switch which one you want at build time: https://github.com/JetBrains/kotlin-mpp-example/blob/master/greeting/build.gradle#L42-L46.
Then xcode can request the device type it wants as part of it's build script, which is visible here but much easier to see if you clone the project and open in xcode: https://github.com/JetBrains/kotlin-mpp-example/blob/master/iosApp/iosApp.xcodeproj/project.pbxproj#L255
m

manijshrestha

12/13/2018, 5:34 PM
is there a way to build the universal framework?
@russhwolf - I am trying to build a library such that it would build a framework that could be included in the iOS project instead of having to hook into the build system.
r

russhwolf

12/13/2018, 5:38 PM
I don't know off-hand. I haven't ever set up a universal framework myself.
t

thevery

12/13/2018, 6:11 PM
@manijshrestha you just need to lipo several archs in one
s

Sam

12/14/2018, 6:36 AM
Beware that to upload the app to the App Store you’ll have to strip out the non-arm architectures or your binary will be rejected. Xcode doesn’t do this automatically.
https://stackoverflow.com/a/50002625/2351 has a helpful script for your Xcode build process.
2 Views