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

Landry Norris

08/03/2021, 2:29 PM
I'm currently using expect/actual for camera operations on Android and iOS. Android's CameraX integrates beautifully with KMM, but I'm noticing that the iOS equivalent is extremely verbose. When I define a Kotlin class that implements the AV...RecordingDelegateProtocol for use with the AVCaptureMovieFileOutput, Kotlin forces me to define a lot of extra functions, such as 'class', conformsToProtocol, isKindOfClass, etc that are not related to the Swift equivalent of the interface In case it helps anyone, subclassing NSObject removes the requirement to implement these extra methods. Has anyone else encountered this while trying to use iOS's camera library in Kotlin using expect/actual? (I'm trying to do this in Kotlin, not Swift, so I can use the result in shared code).
I also have to create several CPointer<ObjCObjectVar<NSObject>s to pass in as parameters, which can add some lines of code. Is the verbosity a natural part of integrating Kotlin and Obj-C, or will this get shorter over time?
m

Michal Klimczak

08/03/2021, 7:21 PM
Stumbled upon it too. Subclassing nsobject is the way to go. Also if you're creating the cpointer for error objects which seems to be required, I don't think it does anything and you can pass nil, I'm not sure though. Couldnt find anything On handling these errors
What I wrote below your thread might be important to you as well
o

okarm

03/25/2023, 12:54 PM
It's two years later and you saved me a nontrivial amount of pain dealing with Core Bluetooth protocols from Kotlin. Thanks!