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

ribesg

01/25/2019, 10:12 AM
Is there an example of a full Kotlin MPP Mobile project? I mean Gradle Kotlin DSL, Android & iOS app with 100% Kotlin
1
I’m still not sure if that’s even possible or viable. Can you use Swift dependencies in an Kotlin iOS app?
b

BenDLH

01/25/2019, 10:16 AM
See the import
Copy code
import platform.Foundation.*
r

ribesg

01/25/2019, 10:19 AM
That’s what I understood but I find the lack of resources and example very weird
And it’s nice with
Foundation
but could I do
Copy code
import platform.RxSwift
or something like that? What would be responsible for managing this dependency? Do I need to have both Carthage and Gradle?
b

BenDLH

01/25/2019, 10:23 AM
Yeah exactly. All examples stop at calling Kotlin from Swift, which looks to be "relatively" easy. But examples of calling Swift from Kotlin are no where to be found
r

ribesg

01/25/2019, 10:26 AM
I’m reading things about Kotlin Native not supporting Swift, so libraries which are not working when called from an ObjC project would not work in Kotlin Native
b

BenDLH

01/25/2019, 10:33 AM
Yeah that makes sense I suppose, that's why you need the @objc annotation on any swift classes you want to access
r

ribesg

01/25/2019, 10:56 AM
I found this https://kotlinlang.org/docs/reference/native/gradle_plugin.html
This document describes Kotlin/Native experimental Gradle plugin, which is not the plugin yet supported by IDE or in multiplatform projects
b

BenDLH

01/25/2019, 11:07 AM
Yeah but C interop must be supported as it's found in the sample projects
Are you on a mac?
r

ribesg

01/25/2019, 11:08 AM
Yes
b

BenDLH

01/25/2019, 12:13 PM
Just ran the demo project I have and it looks like the first build causes the multiplatform gradle plugin to download and link the iOS platform imports. Try building and you should be able to import
platform.*
classes, which are iOS platform Objc classes
Kotlin can't communicate directly with Swift, but exporting Swift code to Objc can be accessed by Kotlin
r

ribesg

01/25/2019, 1:10 PM
The repo I linked doesn’t use the MPP plugin, right?
b

BenDLH

01/25/2019, 1:40 PM
No, that's link is for creating Kotlin libraries to be used by Native/C code only
r

ribesg

01/25/2019, 1:42 PM
Well I’m not sure, this looks like a Kotlin iOS app using share Kotlin code https://github.com/JetBrains/kotlinconf-spinner/tree/master/clients/ios
But it’s not a kotlin-multiplatform project, just multiple gradle projects
3 Views