Hi, guys! KMM is wonderful. Unfortunately, I’ve st...
# multiplatform
p
Hi, guys! KMM is wonderful. Unfortunately, I’ve stumbled to a new obstacle. We need to unzip files on iOS. I have added ZIPFoundation library as CocoaPods dependency to KMM project. ZIPFoundation implements zip archive extraction as an extension to FileManager. Like this.
let fileManager = FileManager()
fileManager.unzipItem(at: sourceURL, to: destinationURL)
As far as I know, there is no access in Kotlin to Swift’s FileManager. Instead we have an access to NSFileManager only. So I’m not able to unzip because FileManager.unzipItem() cannot be called from Kotlin. Is there a workaround for this problem?
b
Define your own unzip function that only takes the path in swift and that should be callable from kt. That fn in swift would just delegate to FileManager
☝️ 1
w
☝️ In our project we usually wrap in the common an interface for such operations, then rely on the Platforms to give back the implementation to the common (via Koin). So platforms are still responsible and don't need to dive into "issues" to import and handle these kind of things in the Kotlin side.
k
I really recommend this presentation about all aspects of K/N interop https://www.droidcon.com/2021/11/17/building-a-kotlin-multi-platform-advanced-library/ by @salomonbrys
❤️ 2
🙌 1
p
@Big Chungus That’s what I did in the end. Thanks!
@Konstantin Tskhovrebov Watched it. Kudos to Salomon for the great talk. Thanks for referring the video. Unfortunately the Kotlin <-> Swift part of the talk turned out way too complicated for our task.
🙏 1