Hey allI I'm trying to use the KVO pattern with AV...
# kotlin-native
a
Hey allI I'm trying to use the KVO pattern with AVPlayer in iOS and I know I need to setup my interop
def
file. I have this setup in gradle:
Copy code
ios {
        compilations.getByName("main") {
            cinterops {
                val observer by creating {
                    defFile(project.file("src/nativeInterop/cinterop/observer.def"))
                    packageName("com.kashif.common")

                    compilerOpts("-I/src/nativeInterop/cinterop")
                    includeDirs {
                        allHeaders("src/nativeInterop/cinterop")
                    }
                }
            }
        }
    }
However when I try to consume the Protocol I'm generating from the def file, it's not importable. I figure I'm missing something basic; any clues?
This is the contents of my def file:
Copy code
language = Objective-C
---
#import <Foundation/Foundation.h>

@protocol NSObjectObserver
@required
- (void)observeValueForKeyPath:(NSString *)keyPath
    ofObject:(id)object
    change:(NSDictionary<NSKeyValueChangeKey, id> *)change
    context:(void *)context;
@end;
SOLUTION: It was something very basic! I had to add:
kotlin.mpp.enableCInteropCommonization=true
to my gradle.properties
a
Never fully understood what
enableCInteropCommonization
does, been trying it on and off for my case with no effect. Cool that it helped yours.