What is `iosX64()` for? Are there some x64 ios dev...
# multiplatform
u
What is
iosX64()
for? Are there some x64 ios devices? I though it was all arm always?
a
I believe iOSX64 is for simulators
u
but there is
iosArm64
which sounds to be a variant, however for simulator there is explicitly
iosSimulatorArm64
a
Because you also have ARM macs that need to do simulation maybe?
u
not sure if I follow, If it truly is a simulator target, then I'm missing the name, but its probably historic thing
b
X64 is an "emulator", not a simulator. In any case, not a real device.
u
in otherwords, if I just target
ios()
, do I then build all these targets, potentially needlessly making builds longer?
b
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
oh, so the last intel macbook would run the iosx64?
b
Correct since simulator requires arm architecture
u
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
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
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
No clue, never worked on mac. All my libs are built tested and published from macs on ci only.
u
I see, thanks!
l
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
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.
511 Views