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

Azur Haljeta

12/14/2020, 9:45 AM
Is it true that only pure Objective-C cocoapods can be included in a KMM project? I found this Starscream library for WebSockets, it seems very popular among iOS developers but it's written in Swift.
nope 1
I have Android covered with OkHttp websockets and also want this for iOS done while keeping the same experience by using IntelliJ and Kotlin
m

mbonnin

12/14/2020, 9:52 AM
I know that doesn't really answer your question but you can also do WebSockets with
NSURLSessionWebSocketTask
on iOS 13+
(which removes the Starscream dependency)
a

Azur Haljeta

12/14/2020, 9:54 AM
@mbonnin I'm already using it, it's available right out of the box... but, I didn't manage to get a callback or notified in any other way when the connection drops or when I turn off Wi-Fi. That's a deal breaker and that's why I need another solution
m

mbonnin

12/14/2020, 9:54 AM
Ouch, yea, that hurts
s

Sam

12/14/2020, 1:32 PM
If the Swift pod exposes an interface for objC, it can be used from Kotlin. You also could write a wrapper in Swift that provides an ObjC interface.
k

Kris Wong

12/14/2020, 2:22 PM
the API that kotlin uses to bridge must be objective-C
or C
z

zsperske

12/14/2020, 2:24 PM
does the documentation cover an example of bridging? or does someone have an article example?
k

Kris Wong

12/14/2020, 2:26 PM
the libcurl sample in the K/N samples repo
👍 1
a

Antoine Lamy

12/14/2020, 2:34 PM
Starscream use
URLSessionWebSocketTask
under the hood anyway, you can take a look at how they use it internally.
m

mbonnin

12/14/2020, 2:42 PM
@Antoine Lamy
Starscream works with iOS 8/10.10
How can it use
URLSessionWebSocketTask
that's only available with iOS 13+ ?
l

louiscad

12/14/2020, 2:45 PM
It probably uses multiple APIs
m

mbonnin

12/14/2020, 2:46 PM
Then I'm wondering what you get by using the
URLSessionWebSocketTask
"backend", I guess smaller binary size
a

Antoine Lamy

12/14/2020, 3:04 PM
On iOS 12+ they use
NWConnection
and bellow that they use Foundation
CFReadStream
👍 1
3 Views