Hey Guys, can someone help me to know if it is pos...
# multiplatform
m
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
you could bundle both into an universal framework
r
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
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
I don't know off-hand. I haven't ever set up a universal framework myself.
t
@manijshrestha you just need to lipo several archs in one
s
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.