https://kotlinlang.org logo
#apollo-kotlin
Title
# apollo-kotlin
m

Mobile Dev.

07/15/2022, 9:31 PM
in kmm why can’t we use apollo library under IOS 13 ?
m

mbonnin

07/15/2022, 9:32 PM
There was something about WebSockets IIRC
Out of curiosity, what is the error you're getting? I remember (but I'm not 100% sure anymore) someone was able to link correctly on below versions
m

Mobile Dev.

07/15/2022, 9:40 PM
What exactly is the purpose of the NSURLSessionWebSocketTask? is that for graphql subscriptions ?
👌 1
m

mbonnin

07/15/2022, 9:40 PM
yes, exactly subscriptions
m

Mobile Dev.

07/15/2022, 9:41 PM
Maybe a version without subscriptions could be released in order to serve users under iOS 13. not sure if that would be hard
for example we are not using any subscriptions whole project and we have a lot of users under ios 13
m

mbonnin

07/15/2022, 9:46 PM
Do you get an error when trying to build your iOS app?
I'm asking because chances are that it's working already or that we can maybe workaround the error if any
m

Mobile Dev.

07/18/2022, 1:36 PM
Sorry for the late response, when i run the app with iphone 5 ( ios 12.4 ) i'm getting this crash
Copy code
dyld: Symbol not found: _OBJC_CLASS_$_NSURLSessionWebSocketMessage
 Referenced from: /Users/alkincakiralar/Library/Developer/Xcode/DerivedData/fizbot-alhlyiyitptqumeebpzkemzcvngh/Build/Products/Debug-iphonesimulator/Bifrost.framework/Bifrost
 Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation
 in /Users/alkincakiralar/Library/Developer/Xcode/DerivedData/fizbot-alhlyiyitptqumeebpzkemzcvngh/Build/Products/Debug-iphonesimulator/Bifrost.framework/Bifrost
dyld: launch, loading dependent libraries
DYLD_FRAMEWORK_PATH=/Users/alkincakiralar/Library/Developer/Xcode/DerivedData/fizbot-alhlyiyitptqumeebpzkemzcvngh/Build/Products/Debug-iphonesimulator:/Users/alkincakiralar/Library/Developer/Xcode/DerivedData/fizbot-alhlyiyitptqumeebpzkemzcvngh/Build/Products/Debug-iphonesimulator/PackageFrameworks
DYLD_FALLBACK_LIBRARY_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib
DYLD_ROOT_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.4.simruntime/Contents/Resources/RuntimeRoot
DYLD_FALLBACK_FRAMEWORK_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.4.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks
DYLD_INSERT_LIBRARIES=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 12.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
(lldb)
although i'm not using any graphql subscription method, i only use query and mutation
m

mbonnin

07/18/2022, 1:37 PM
Alright 👍
SOunds like it crashes at start time, right?
m

Mobile Dev.

07/18/2022, 1:39 PM
yes at start time, also i just implement the library with spm and didn't import any viewcontroller or classes
m

mbonnin

07/18/2022, 1:40 PM
I see. Mind opening an issue about this?
m

Mobile Dev.

07/18/2022, 1:41 PM
You want me to open an issue about it ?
m

mbonnin

07/18/2022, 1:42 PM
Yes please. Doesn't look easy to workaround unfortunately 😞
So we'll have to go the route of separate dependencies
m

Mobile Dev.

07/18/2022, 1:43 PM
i see, im gonna open an issue thanks for your help 👍
🙏 1
m

mbonnin

07/18/2022, 1:44 PM
For the record, I just bumped into the previous issue that was mentioning this
Looks like a lot of users are on iOS 13+ these days so it'll be hard to prioritize work on this but please open an issue nevertheless as some other folks from the community might be interested in contributing
m

Mobile Dev.

07/18/2022, 1:46 PM
Should i open the ticket as bug report or feature request ?
m

mbonnin

07/18/2022, 1:46 PM
"it depends" 🙂
It doesn't matter much to be honest. More like a feature request I'd say because the limitation is documented currently but feel free to file it as a bug if it's blocking for you
m

Mobile Dev.

07/18/2022, 2:06 PM
thanks for your help
m

mbonnin

07/18/2022, 2:06 PM
Thanks for reporting this 💙
👍 1
p

Paddy O'Brien

07/27/2022, 7:23 PM
Seeing this same issue. Do you happen to have a path for the websockets stuff on 3.x? The link in the original issue appears to be broken.
m

mbonnin

07/27/2022, 10:19 PM
@Paddy O'Brien do you need websockets on iOS < 13 or do you just need the regular queries to work on iOS < 13?
• Making regular queries work on iOS < 13 is a matter of removing the dependency and shuffling how the artifacts are built • Making websockets work on iOS < 13 is a whole different issue as it'll required bundling starscream or another library since the OS doesn't support WebSockets
p

Paddy O'Brien

07/28/2022, 1:09 PM
Nah we just need regular queries to work, Shopify doesn’t use subscriptions. Was just looking for the path where the socket stuff has moved to as it seems to have changed between 2.x and 3.x.
I was wondering about something though. The iOS library does an excellent job of separating out this concern by introducing the
NetworkTransport
protocol was wondering why not a similar approach on Kotlin.
I guess really KMM just needs to add os version detection 😬 https://youtrack.jetbrains.com/issue/KT-37180
m

mbonnin

07/28/2022, 1:19 PM
Gotcha 👍. It's 100% doable. We have the
NetworkTransport
API as well as a lower level
WebSocketEngine
one. The trick here is to do it in a backward compatible way. That certainly means splitting the current
apollo-runtime
that has a hard dependency on iOS13+ at the moment and introducing separate artifacts, one of those without the iOS13+ dependency
For the record, I don't think anything changed regarding this between 2.x and 3.x? Both versions use nsurlsessionwebsockettask
p

Paddy O'Brien

07/28/2022, 1:22 PM
They do, the location of the code just changed. The link in the initial issue you found with Ellen and Ivan seems to be broken. I think I found it though. building now 😄
m

mbonnin

07/28/2022, 1:23 PM
What link?
(there's gazillions links in that issue 😅 )
m

mbonnin

07/28/2022, 1:24 PM
Gotcha
p

Paddy O'Brien

07/28/2022, 1:24 PM
I get a 404
m

mbonnin

07/28/2022, 1:24 PM
Yea, it's using
main
p

Paddy O'Brien

07/28/2022, 1:25 PM
looks like everything is now in NSURLWebsocketEngine.kt
lol, beat me to it
thanks!
m

mbonnin

07/28/2022, 1:26 PM
If you remove everything in that file with
TODO("make this work with iOS < 13")
, you should be able to link and run everything
p

Paddy O'Brien

07/28/2022, 1:27 PM
Everything? I tried to leave it as an empty type but im getting errors
m

mbonnin

07/28/2022, 1:28 PM
Something like this should do the job:
Copy code
actual class DefaultWebSocketEngine : WebSocketEngine {
  override suspend fun open(url: String, headers: List<HttpHeader>): WebSocketConnection {
    TODO("Not yet implemented")
  }

  override suspend fun open(url: String, headers: Map<String, String>): WebSocketConnection {
    TODO("Not yet implemented")
  }

}
(not tested but the API is relatively small, there shouldn't be too much needed besides that)
p

Paddy O'Brien

07/28/2022, 2:13 PM
Seems to have done the trick, Thanks
m

mbonnin

07/28/2022, 2:13 PM
Sure thing!
6 Views