I have some problems with cinterops. I’m trying to...
# kotlin-native
r
I have some problems with cinterops. I’m trying to add this to my iOS project: https://material.io/develop/ios/components/textfields/ My def file is like this:
Copy code
depends = Foundation
package = framework.MaterialTextFields
language = Objective-C
headers = MaterialTextFields.h MaterialTextFields+Theming.h

compilerOpts = -framework MaterialComponents
linkerOpts = -framework MaterialComponents
My problem is that when I run cinterops I get this error:
Copy code
Exception in thread "main" java.lang.Error: /Users/ribesg/XcodeProjects/events/Pods/MaterialComponents/components/TextFields/src/Theming/MDCTextInputControllerFilled+MaterialTheming.h:15:9: fatal error: 'MaterialComponents/MaterialContainerScheme.h' file not found
I found that
MDCTextInputControllerFilled+MaterialTheming.h
contains this line
#import <MaterialComponents/MaterialContainerScheme.h>
and cinterops does not seem to understand it properly. I do have this
MaterialContainerScheme.h
file in the context but it’s not in a folder/module/whatever called
MaterialComponents
I guess. How do I make this work?
a
Maybe you can try to to include this header into the def file, with specifying it’s location? IMO it seems like this header should be imported along with this theming one anyway, if I understand this example in the documentation correctly(https://material.io/develop/ios/components/textfields/#theming-extensions)
Also, don’t you tried to apply cocoapods plugin here?
r
I tried but failed because I’m not creating a library here but an app and the plugin does not seem to be made for that purpose
r
@Artyom Degtyarev [JB] if I just add the header it said it cannot find, then it cannot find another one from that header I add. Adding the other one it doesn’t find doesn’t help. Well that’s unclear, but see this screenshot:
MaterialColorScheme.h
is found and imported successfully but it then still crashes on the next one because it knows
MaterialColorScheme.h
but not
MaterialComponents/MaterialColorScheme.h
message has been deleted
@alex009 I see that you have
modules
in your
def
file, what does that do? Maybe I need that?
a
modules needed to linker. compilator will link your library with external modules
in your case header not found. You should pass frameworks to compiler with absolute path, like here: https://github.com/icerockdev/moko-maps/blob/1e2af5a74545a261ceeec4c794ddf8678a2ebe81/maps-google/build.gradle.kts#L67
r
I do pass the
MaterialComponents
framework compiled by cocoapods which is located in the TARGET_BUILD_DIR but I’m trying to cinterops the content of
Pods
, not the built frameworks. That’s probably an issue
Oh so modules in def replace headers. I’ve got something that compiles, let’s see
Ok it works. Using modules instead of headers worked. The only problem I have is that I can’t find a way to build the frameworks from Pods without XCode, so I can no longer run cinterops without XCode 😞 Oh well.