I have seen in iOS tutorials that `.frameworks` ca...
# multiplatform
p
I have seen in iOS tutorials that
.frameworks
can contain
.swift
files in it. Is there a way to put swift files in the KMP generated framework. Either a custom Gradle task or Xcode build phase batch script? Anything?
👀 1
b
I had a similar requirement for my library and got a suggestion how to have iOS native code directly in my KMP library. You can see it here: https://kotlinlang.slack.com/archives/C9JM6Q2UX/p1712863578941529 I didn’t put that much energy to it and at the first try I couldn’t make it work for my use case. Need to find some additional time for deeper look at it. I hope that suggested approach in the thread will gave you some idea or direction for your use case.
p
I just replied in your thread. I think KMP-ViewModel is basically doing the approach that I am following right now. Which is basically distribute the library in 2 parts. A KMP dependency(holding abstractions) that gets added to the commonMain/iOSMain and a swift package(holding implementations) somewhere. But this is what I want to avoid, although is not a big deal TBH but would be way easier if some gradle task included the
.swift
files in the .
xcFramework
.
👍 1
But answering my self 🤔, perhaps including swift files in the framework is a disadvantage. If you have third party dependencies then you would have to manually imported in Xcode. Otherwise using SPM it will bring the 3rd party dependencies automatically. So probably the best way is to distribute the library in 2 parts.
👍 1