Skolson5903
02/22/2022, 7:41 PMimport platform.Compression
statement can work, not a third-party cocoapod, so I can import it and use it in KMP code. I'm still searching around but so far not having much luck. Thanks in advance for any info...Marc Dietrichstein
02/23/2022, 8:21 AMactual class CompressedLineWriter actual constructor(filePath: String) {
private val writer = PrintWriter(GZIPOutputStream(File(filePath).outputStream()))
actual fun writeLine(line: String) {
writer.println(line)
}
actual fun close() {
writer.close()
}
}
I guess on iOS I could achieve the same thing with the Compression Framework [1]. But just like you I am unable to access it with Kotlin.
One reason for this could be that it might be a Swift-only framework, but Kotlin only supports Objective-C frameworks.
I might be able to implement my use case with platform.zlib
, but that will involve a lot of pointer handling and manual memory management that I'm really not looking forward to.
[1] https://developer.apple.com/documentation/accelerate/compressing_and_decompressing_files_with_swift_stream_compressionSkolson5903
02/23/2022, 4:38 PM.konan/kotlin-native-prebuilt-windows-x86_64-1.6.10\konan\platformDef\ios_arm64
there are a bunch of .def files but Compression isn't one of them. So now I'm looking in the Apple SDK to find if there is a libcompression file someplace - search hits have shown references to this but I haven't found it yet. If I can find that and the associated headers I can do my own cinterop setup. Also have a "wild hare" chase 🙂 in mind, considering porting pieces of jzlib project (java ZLib) to KMP, will see where that goes. Also in case its useful, if you haven't already check out https://github.com/korlibs/korio, they have a KMP port of compression too. Their Zip file support is insufficient for me, and their port of Compression uses a lot of other stuff in their library, and I haven't used it so don't know how good it is, but its there 🙂Marc Dietrichstein
02/23/2022, 7:01 PMplatform.darwin
, for example import platform.darwin.compression_stream_process
and a bunch of other symbols which are available since iOS 9.0.
Everything available since iOS 13 (like OutputFilter
) however is missing. Maybe those are Swift-specific blob shrugSkolson5903
02/24/2022, 9:56 PM