Hi hi everyone :wave: I have a question related o...
# multiplatform
j
Hi hi everyone 👋 I have a question related of how the KMM frameworks handles the builds... when you create a default KMM project in Android Studio, an iOSapp folder is created, but, do this sub-module is for iOS running on 64bits (intel) Macs? How is it compiled for a real iOS device? I ask this because I changed to an M1 Mac and I realized that I had to add the
iosSimulatorArm64
sourceSet in the gradle file in order to generate de Framework and compile the project in XCode Or maybe is there something that I'm missing?
a
So KMM compiles to three binaries, x64 simulator(Intel based Mac), x64 device(iOS phone) and arm simulator(M1 Mac) if I'm not mistaken. This will be automatically configured when you create a new KMM project.
h
Hi @Jose Flavio, if you use M1 macbook and not select Rosetta for your Xcode, you can ignore Intel based target. For arm64 simulator, you can add the target in the way,
Copy code
val xcf = XCFramework()   // if you use xcframework. otherwise, you can remove it.
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            xcf.add(this)   // use for xcframework
        }
    }
You do not need to have sourceSet for each platform, unless you have special handing for simulator or device.
j
@Hee Fan @ayodele thank you guys! So, we could say: •
iosArm64
→ generates Framework/compile for iPhone device •
iosSimulatorArm64
→ generates Framework/compile for simulator in XCode Correct? However, since iOS in an iPhone is an arm64 operating system, why
iosArm64
would not work for iOS simulator? 🤔
h
Hi @Jose Flavio, sorry for late reply. you are right on iOSArm64 and iOSSimulatorArm64. This is two different iOS targets although they both consume arm cpu. In fact it is required by Apple, not kotlin. If you open xcframework, you can see the two Arm targets. Apple Silicon CPUs are based on ARM, and they have many series. Macbook use
M
series, and iPhone use
A
series. Apple silicon - Wikipedia. therefore, the generated targets are different.
🙌 1