bendb
09/21/2023, 3:11 AMNetwork.framework
and hitting seemingly-unavoidable runtime exceptions from the kotlin<>objc interop layer. Specifically, common functions like nw_connection_send
and nw_connection_receive
take block arguments that return void
. The Kotlin compiler will happily accept a function literal:
nw_connection_send(conn, data, NW_CONNECTION_DEFAULT_MESSAGE_CONTEXT, false) { networkError -> ... }
but at runtime, this blows up pretty spectacularly:
2023-09-20 20:39:39.221 test.kexe[91736:4026442] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Converting Obj-C blocks with non-reference-typed return value to kotlin.Any is not supported (v)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010cdd178b __exceptionPreprocess + 242
1 libobjc.A.dylib 0x000000010b8ebb73 objc_exception_throw + 48
2 CoreFoundation 0x000000010cdd1669 -[NSException initWithCoder:] + 0
3 test.kexe 0x0000000102e84647 _ZL16blockToKotlinImpP11objc_objectP13objc_selectorPP9ObjHeader + 679
4 test.kexe 0x0000000102eb373d Kotlin_Interop_refFromObjC + 61
5 test.kexe 0x0000000102e56599 kfun:com.bendb.repro.NwSocket#write(kotlin.ByteArray;kotlin.Int;kotlin.Int){} + 1993
// so on, so forth
Is this business-as-usual? It seems weird that such a prominent framework, and such a common Apple API style, would be unsupported like this.