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

ursus

02/19/2023, 6:51 PM
What is
iosX64()
for? Are there some x64 ios devices? I though it was all arm always?
a

Arjan van Wieringen

02/19/2023, 7:05 PM
I believe iOSX64 is for simulators
u

ursus

02/19/2023, 7:21 PM
but there is
iosArm64
which sounds to be a variant, however for simulator there is explicitly
iosSimulatorArm64
a

Arjan van Wieringen

02/19/2023, 7:51 PM
Because you also have ARM macs that need to do simulation maybe?
u

ursus

02/19/2023, 7:52 PM
not sure if I follow, If it truly is a simulator target, then I'm missing the name, but its probably historic thing
b

Big Chungus

02/19/2023, 8:57 PM
X64 is an "emulator", not a simulator. In any case, not a real device.
u

ursus

02/19/2023, 8:59 PM
in otherwords, if I just target
ios()
, do I then build all these targets, potentially needlessly making builds longer?
b

Big Chungus

02/19/2023, 9:05 PM
Depends on what you want. If you want to run the app on emulator, you need x64. For simulators on m2 macs you need iosSimulatorArm64. For actual iphones you need iosArm64
u

ursus

02/19/2023, 9:06 PM
oh, so the last intel macbook would run the iosx64?
b

Big Chungus

02/19/2023, 9:07 PM
Correct since simulator requires arm architecture
u

ursus

02/19/2023, 9:09 PM
I see, so how to set it up, is it literally 3x the build time if I were to target iosx64, iosarm64, iosarmSimulator? is it worth setting just one for development?
b

Big Chungus

02/19/2023, 9:10 PM
Not really since simulator is skipped on intel macs and x64 is skipped on m2
Plus you can always run explicit gradle build task for a single target instead of generic "build" that builds everything it can.
u

ursus

02/19/2023, 9:12 PM
yea thats true, but when running the default ios run configration in AS, is it smart enough not to build both arm64 and arm64simulator?
b

Big Chungus

02/19/2023, 9:13 PM
No clue, never worked on mac. All my libs are built tested and published from macs on ci only.
u

ursus

02/19/2023, 9:14 PM
I see, thanks!
l

Landry Norris

02/19/2023, 11:55 PM
The cocoapods setup is smart enough to build the required arch. If you check the podspec, you can see it pass the arch to the build task. I believe the packXCFramework task is too, but less sure on that one.
d

Daniel Seither

02/20/2023, 9:38 AM
As an aside, it’s called the iOS Simulator, no matter whether it is running on an Intel Mac or an Apple Silicon Mac. This is because in contrast to the Android Emulator which emulates a full Android device, the iOS Simulator is basically only a translation layer on top of macOS that doesn’t run iOS but only translates between iOS and macOS calls. This is why it’s not possible to run iPhone builds (iosArm64) in a simulator (iosSimulatorArm64), even though both share the same CPU architecture. And this is also why on Intel Macs, an x64 build is needed for the simulator. I agree that it is confusing that the simulator targets are called iosX64 for Intel but iosSimulatorArm64 for Apple Silicon in Kotlin Native, but I guess we need to live with it for the time being 🤷 Back to topic: If you care about build time during development, it can make sense to only build for the platform you’re developing with (probably iosSimulatorArm64). We’re not using CocoaPods but generate an XCFramework directly and have a Gradle setup that makes it possible to build only that target, cutting build time significantly compared to rebuilding for all platforms during rapid iteration.
292 Views