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

Kruger Brent

06/06/2019, 7:31 PM
Screen Shot 2019-06-06 at 3.27.55 PM.png
d

Dominaezzz

06/06/2019, 7:32 PM
Is that a multi module project?
If it is, can I see your
settings.gradle.kts
?
k

Kruger Brent

06/06/2019, 7:33 PM
yeah sure.. it is one of the sample projects on kotlin?native github that demonstrates the ability to use a cocoapod in kotlin
pluginManagement { repositories { jcenter() maven { setUrl("https://dl.bintray.com/kotlin/kotlin-dev") } maven { setUrl("https://dl.bintray.com/kotlin/kotlin-eap") } } resolutionStrategy { val kotlin_version: String by settings eachPlugin { when { requested.id.id == "org.jetbrains.kotlin.native.cocoapods" || requested.id.id == "kotlin-native-cocoapods" -> useModule("org.jetbrains.kotlinkotlin gradle plugin$kotlin_version") requested.id.id.startsWith("org.jetbrains.kotlin") -> useVersion(kotlin_version) } } } }
d

Dominaezzz

06/06/2019, 7:35 PM
Is that it? You need to add
include(":cocoapods")
at the bottom.
Basically add it to the root project.
k

Kruger Brent

06/06/2019, 7:36 PM
exactly, I was wondering how was that getting linked at all?
so where do I add that line of code?
d

Dominaezzz

06/06/2019, 7:38 PM
In
settings.gradle.kts
.
k

Kruger Brent

06/06/2019, 7:38 PM
okay, I added that in the settings.gradle
but it's not able to detect and pick the change
it's throwing an error from the file
d

Dominaezzz

06/06/2019, 7:39 PM
Hmm, it might be an issue with the submodule path.
What's the error?
k

Kruger Brent

06/06/2019, 7:40 PM
* What went wrong: An exception occurred applying plugin request [id: 'org.jetbrains.kotlin.jvm', version: '1.3.40-eap-40']
Failed to apply plugin [id 'org.jetbrains.kotlin.jvm']
> Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
and this error is in build.gradle.kts
this is my
build.gradle.kts
d

Dominaezzz

06/06/2019, 7:43 PM
You can't specify version multiple times.
On line 4, remove the version bit.
k

Kruger Brent

06/06/2019, 7:44 PM
yeah I removed it, but it still says this
* What went wrong:
An exception occurred applying plugin request [id: 'org.jetbrains.kotlin.jvm', version: '1.3.40-eap-40']
> Failed to apply plugin [id 'org.jetbrains.kotlin.jvm']
> Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
d

Dominaezzz

06/06/2019, 7:44 PM
Ohhhhhh
k

Kruger Brent

06/06/2019, 7:45 PM
something to do with the
kotlin(''jvm")
i guess
d

Dominaezzz

06/06/2019, 7:45 PM
You can't do both multiplatform and jvm.
Pick one.
Probably multiplatform.
k

Kruger Brent

06/06/2019, 7:45 PM
okay. cool. let me try that.
oh yeah that worked. Thanks a lot. Appreciate it!
d

Dominaezzz

06/06/2019, 7:46 PM
No problem.
k

Kruger Brent

06/06/2019, 7:47 PM
but this error still persists
I included it as a sub-module
d

Dominaezzz

06/06/2019, 7:48 PM
Try removing the colon.
k

Kruger Brent

06/06/2019, 7:50 PM
The
cocoapods
is the root right, and aren't we adding that as a submodule to
kotlin-library
project, whereas shouldn't it be the other way?
yeah removed the colon, and executed
gradle build
command, no luck
d

Dominaezzz

06/06/2019, 7:51 PM
Hmm, I'm not sure. What does your project folder look like?
k

Kruger Brent

06/06/2019, 7:51 PM
d

Dominaezzz

06/06/2019, 7:53 PM
I now see why the IDE might be confused.
You don't need that
include
btw.
k

Kruger Brent

06/06/2019, 7:53 PM
okay, what's your inference
oh
but how do we link the both
d

Dominaezzz

06/06/2019, 7:56 PM
I think idea wants
kotlin-folder
to be the root directory.
But that won't work for you I think.
So I think you could maybe...... I'm not too sure tbh.
k

Kruger Brent

06/06/2019, 7:59 PM
okay, I got it. I shouldn't even be bothered by that, because we shouldn't be trying to link that from intelliJ as I understand. Now since I am able to generate podspec successfully, I navigated to the ios-app folder and ran a
pod install
and an xcworkspace was generated. Now when I launch in Xcode, it opens up with the
kotlin-library pod
.
d

Dominaezzz

06/06/2019, 8:01 PM
Oh okay. Well, if you really want IntelliJ then you can always open just the
kotlin-library
folder.
Small tip.
maven("......")
is slightly shorter than
maven { setUrl("......") }
.
k

Kruger Brent

06/06/2019, 8:01 PM
cool. Thanks. makes sense, I will update the file.
When I try to build the project in Xcode, it's throwing some weird error.
sorry to bother you again!
d

Dominaezzz

06/06/2019, 10:08 PM
I've seen this in an issue before.....
Try setting that property.
i

ilya.matveev

06/07/2019, 10:57 AM
This property is used to replace the default Kotlin/Native compiler used by the Gradle plugin with a local distribution. Since this sample is included in the K/N repo, it has this property specified to use a compiler built from sources. So you may just remove
org.jetbrains.kotlin.native.home
from your
gradle.properties
and rerun the build.
👏 1
k

Kruger Brent

06/07/2019, 2:21 PM
@ilya.matveev that worked like a charm. Thanks a lot.
@Dominaezzz yeah, I did as IIya Matveev said and it worked.
👍🏼 1
4 Views