this may have beeen asked already, but is there an...
# kotlin-native
a
this may have beeen asked already, but is there any example ios projects written in kotlin using cocoapods? does konan do the proper linking to them, or is there a way via gradle to include them?
o
I am not aware of such projects, however we are considering adding such feature, so please let us know more of your requirements and current status (maybe via Github/Youtrack issue)
a
ok thanks for responding. yeah having a common template for appcode that creates a kotlin native project with cocoapods ready or a writeup on how to add support for it within existing project would be useful. as it stands we have to link frameworks through
c_interop
?
j
I'm using a cocoapod within my Kotlin code compiled into a framework. You have to do the typical work of making sure your iOS project links in the Cocoapods along with the Kotlin framework. Also you need to create an interop stub for the cocoapod.
a
Do you have an example of interop stub?
j
Sure, this one is for FMDB
Copy code
language = Objective-C
package = platform.cocoapods.fmdb
headers = /full/path/to/project/Pods/FMDB/src/fmdb/FMDB.h
compilerOpts = 
linkerOpts= -lsqlite3
I'm not certain if a relative path can be used in the interop stub above.
a
Ok thank you. I will try it. I was getting an exception about missing arguments in the program. Complaining about missing output arguments or something.
j
@olonho can .def files use relative paths to headers? If not is there a variable that can be used for the project path?
m
Relative path works in gradle, like this:
includeDirs "${System.getProperty("user.dir")}/relative/path"
or maybe better
"${project.rootDir}/relative/path"
o
sure, probably the best approach is to use
-compilerOpts -I<search path>
or matching Gradle settings, as Mike mentioned. This way
.def
file will contain only relative path and build system will figure out where
cinterop
shall search for headers. Pretty much the same approach as used by C compilers (and
cinterop
is technically a special purpose C compiler itself)
j
Thanks, using
konanArtifacts.interop.includeDirs
within the Gradle build file with the
${project.rootDir}
prefix did the trick.
a
ok so I am getting this error:
Copy code
> Task :ios:app:compileKonanAppIos_x64 FAILED
error: you have not specified any compilation arguments. No output has been produced.
here is my file (apppackage is stubbed with real name):
Copy code
language=Objective-C
linkerOpts=-framework Accelerate -framework CoreGraphics -framework CoreData -framework CoreLocation -framework CoreText -framework GLKit -framework ImageIO -framework OpenGLES -framework QuartzCore -framework SystemConfiguration
package=${apppackage}
compilerOpts=
linkerOpts=
o
You need
headers
property here as well, otherwise interop has no idea what to use for declaration translation
a
and that should point to something? it doesnt seem mandatory. whats confusing is the error message mostly.
also adding it still produces same issue
o
Please create an issue, there’s not enough context
a
ok sure thing