How is the status om running KMM on iOS simulator ...
# multiplatform
b
How is the status om running KMM on iOS simulator on M1 Mac? I create new project using latest version. Can run on device but not on simulator.
ld: warning: ignoring file /Users/xxxx/project/android/yyyy/shared/build/cocoapods/framework/shared.framework/shared, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64
Undefined symbols for architecture arm64:  "_OBJC_CLASS_$_SharedGreeting", referenced from:    objc-class-ref in ContentView.o ld: symbol(s) not found for architecture arm64
2
o
you just need to add arm64 to exculded architectures from build settings.
b
That leads to other error where it can no longer find shared framework "No such module 'shared'"
And "ld: framework not found Pods_iosApp"
Switching run target to device and it works
So, no simulator and ni swiftui preview because build fail.
b
If you’re using the packForXCode task to generate the framework from KMM, it could be that the default implementation is assuming that simulators can only be x86
I believe there’s an env var that xCode sets with the architecture, you could try using that. An alternative could be to use a FatFramework (universal) or cocoapods which should take care of this automatically
o
if you're using pod, try pod install on ios directory
s
You can't run the iOS Simulator from Xcode on Apple M1 right now. It's not possible. Start it from the KMM plugin in Android Studio.
Even fat frameworks or XCFramework will not help you since the "arm64" Kotlin Native target will build for real devices only, never for simulators. This will be fixed with 1.5.30 AFAIK
o
I'm running iOS Simulator from Xcode on my Apple M1.
s
How?
How did you build arm64 for simulator?
o
I didn't do anything different than another ios project. just added arm64 to excluded architectures. screenshot is on the top
s
So you run the iOS Simulator for x64?
o
Well, I'm not really sure of it. But when I run my project from Xcode, It works
b
Made new project and used framework instead of cocoa pods. Tried to run, got original error. Added the exclude architecture. Now run simulator from xcode and swiftui preview works.
👍 1
s
Ok, maybe I should try it again.
Lol, okay... I tried exactly that several times and it did not work but now it does... strange. But I think I did not build a XCFramework / fat framework by that time. Not sure anymore. Ok, running x64 simulator on M1 in xcode is possible now.
I'm happy now 😀
b
There are so many moving parts with kotlin,KMM, iOS, Xcode, gradle... Been using KMM for 2 years but still new things coming up. (still best way to build multiplatform app though)
👍 1
s
So nice to finally have a SwiftUI preview working.
o
great. glad it helped 😁
411 Views