Kotlin-native: Missing documentation about `konanArtifacts.framework()`

Created on 3 Jan 2018  路  6Comments  路  Source: JetBrains/kotlin-native

In the calculator readme we use in the kotlinArtifcats gradle extensions framework().
I guess I know what it means and what it does.
It build a iOS framework with the we passed in.

But it isn't well documented here.
It would be great if someone can add this who have deep knowledge what we can pass in into the framework() and what it really does...

Most helpful comment

@mouse4d
I have a blog post of creating Kotlin Native iOS project without CLion:

You can check it here:
http://www.albertgao.xyz/2018/01/14/how-to-create-kotlin-native-ios-project/

Two ways:

  1. Implement all the iOS-side code in Kotlin
  2. Generate KN code as an iOS framework and use it in a XCode project

Seems fine to me, just post here to see if it could help you.

All 6 comments

I would also add that it would've been fantastic if there was a sample doing the same with CMake in CLion!

Background: I'm an iOS developer looking for a possibility to reuse code for an iOS and Android library (actually .framework and .jar). I have no experience with any of CMake, gradle, or kotlin, but from what I could wrap my head around - Kotlin Native looks really promising and far more attractive than a C++ lib.

Hey @mouse4d

you can take a look into the calculator sample. There is "everything included" how to build a jar and a framework side by side...
The jar can be easily published to any maven repo (for example) or directly within a android project.

I've also created a sample here which do exactly that.
Before the andorid app builds it generate the jar from the shared code and put it to the android dependencies.

Hi @StefMa

thanks a lot for the hint, I did look into all examples and those are really helpful!

But what I meant is that I tried creating a .framework from a CLion project (which of course is using CMake) having as a starting base the HelloWorld sample project (chosen when creating a new Kotlin Native project) and I got a little bit confused, because while there are the CMake functions for library and executable artefacts in the KotlinCMakeModule (konanc_library and konanc_executable) I couldn't find the konanc_framework function that would correspond to framework() used inkotlinArtifcats gradle extensions.*

I hope this made sense :D

So I added my background with the hope that it will motivate the people writing the docs to try to make them more "idiot proof", because there might be more developers like me that know nothing about any of the toolchains used but still want to give Kotlin Native a shot, and for them (me) the learning curve is not really a curve but almost a vertical! 馃檭

* this, by the way, I solved by copying the konanc_library function and changing .klib to .framework and -produce library to -produce framework. I don't know where I could contribute this though.

@mouse4d
I have a blog post of creating Kotlin Native iOS project without CLion:

You can check it here:
http://www.albertgao.xyz/2018/01/14/how-to-create-kotlin-native-ios-project/

Two ways:

  1. Implement all the iOS-side code in Kotlin
  2. Generate KN code as an iOS framework and use it in a XCode project

Seems fine to me, just post here to see if it could help you.

@mouse4d Yes, currently there is no support for frameworks in CMake (because our main target is still Gradle) but it's should be easy to add such a support. I think we'll do this.
The #1247 PR with some readme updates is merged so I think the issue may be closed.

Was this page helpful?
0 / 5 - 0 ratings