I cannot get Kotlin native working with the new Sw...
# kotlin-native
t
I cannot get Kotlin native working with the new SwiftUI. The app works fine in the simulator, but if I want to see a preview in Xcode I get this error:
Copy code
Terminating app due to uncaught exception 'NSGenericException', reason: 'Only one Kotlin framework can be loaded currently'
terminating with uncaught exception of type NSException
g
I’m not really sure how this rrelated to SwiftUI and how preview works, K/N allows only one K/N framework per app, so you cannot write 2 k/n frameworks and include them to single application, you have to merge them
t
@gildor this is related to the SwiftUI preview. I only have one K/N framework, the app in the simulator works fine. It is just that the preview in Xcode is not working.
g
Probably it’s some sort magic on preview
what you exactly doing? Do you try to use K/N frameowrk in a project with SwiftUI?
t
Yes. I have a current iOS project with K/N. I changed the iOS deployment target to 13.0. Then I added a SwiftUI file using Xcode and the preview crashes.
g
I see, interesting
s
It could be a bug in the Xcode beta. Maybe it is trying to load your framework twice.
s
Can’t reproduce. Could you share your project and steps to reproduce the bug?
t
@svyatoslav.scherbina Yes, of course. I created an issue on GitHub, with a link to a sample project. It looks like it is related to the CocoaPods plugin. Are you able to reproduce the issue with this project? https://github.com/JetBrains/kotlin-native/issues/3059
s
Thanks! We will check it in a few days.
👍 1