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

Bill Mårtensson

06/24/2021, 11:00 AM
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

Osman Saral

06/24/2021, 12:56 PM
you just need to add arm64 to exculded architectures from build settings.
b

Bill Mårtensson

06/24/2021, 1:02 PM
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

borisdamato

06/24/2021, 1:43 PM
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

Osman Saral

06/25/2021, 6:50 AM
if you're using pod, try pod install on ios directory
s

Stefan Oltmann

06/29/2021, 11:31 AM
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

Osman Saral

06/29/2021, 11:39 AM
I'm running iOS Simulator from Xcode on my Apple M1.
s

Stefan Oltmann

06/29/2021, 11:39 AM
How?
How did you build arm64 for simulator?
o

Osman Saral

06/29/2021, 11:41 AM
I didn't do anything different than another ios project. just added arm64 to excluded architectures. screenshot is on the top
s

Stefan Oltmann

06/29/2021, 11:41 AM
So you run the iOS Simulator for x64?
o

Osman Saral

06/29/2021, 11:42 AM
Well, I'm not really sure of it. But when I run my project from Xcode, It works
b

Bill Mårtensson

06/29/2021, 12:54 PM
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

Stefan Oltmann

06/29/2021, 12:54 PM
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

Bill Mårtensson

06/29/2021, 1:06 PM
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

Stefan Oltmann

06/29/2021, 1:10 PM
So nice to finally have a SwiftUI preview working.
o

Osman Saral

06/29/2021, 7:51 PM
great. glad it helped 😁
290 Views