Screen Shot 2019-06-06 at 3.27.55 PM.png
# multiplatform
k
Screen Shot 2019-06-06 at 3.27.55 PM.png
d
Is that a multi module project?
If it is, can I see your
settings.gradle.kts
?
k
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
Is that it? You need to add
include(":cocoapods")
at the bottom.
Basically add it to the root project.
k
exactly, I was wondering how was that getting linked at all?
so where do I add that line of code?
d
In
settings.gradle.kts
.
k
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
Hmm, it might be an issue with the submodule path.
What's the error?
k
* 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
You can't specify version multiple times.
On line 4, remove the version bit.
k
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
Ohhhhhh
k
something to do with the
kotlin(''jvm")
i guess
d
You can't do both multiplatform and jvm.
Pick one.
Probably multiplatform.
k
okay. cool. let me try that.
oh yeah that worked. Thanks a lot. Appreciate it!
d
No problem.
k
but this error still persists
I included it as a sub-module
d
Try removing the colon.
k
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
Hmm, I'm not sure. What does your project folder look like?
k
d
I now see why the IDE might be confused.
You don't need that
include
btw.
k
okay, what's your inference
oh
but how do we link the both
d
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
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
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
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
I've seen this in an issue before.....
Try setting that property.
i
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
@ilya.matveev that worked like a charm. Thanks a lot.
@Dominaezzz yeah, I did as IIya Matveev said and it worked.
👍🏼 1