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

Bailey Pollard

06/16/2021, 1:40 PM
Hey folks, currently in the process of following this guide to implement a cocoapods dependancy, but keep getting this error when I build. Am I missing a step that was skipped in the documentation?
v

Viacheslav Kormushkin

06/16/2021, 2:03 PM
May be related to https://youtrack.jetbrains.com/issue/KT-44155 Try calling useLibraies() in cocoapods block
t

Tiago Nunes

06/16/2021, 2:08 PM
I think a lot of things can cause this. Is your library a pure Swift library? Is the spec.source_files setting correct in the library podspec? Also, can you please delete your message in my previous thread? People might think it's answered. Thanks 🙂
Have you tried to import the library with cocoapods in an ios project?
b

Bailey Pollard

06/16/2021, 2:23 PM
@Tiago Nunes Yep, this imports correctly in a regular ios project
podspec file is generated correctly... this error even happens while importing pod("AFNetworking")
What am I suppose to do with the podspec file? Maybe I am missing something there
t

Tiago Nunes

06/16/2021, 2:28 PM
We got that issue once when our ios library podspec wasn't setup correctly, but if you can use it in ios projects, that shouldn't be your problem.
Are you aiming for the X86_64 simulator?
b

Bailey Pollard

06/16/2021, 2:29 PM
Yes
Do I have to rename my iosMain dir to something else?
t

Tiago Nunes

06/16/2021, 2:31 PM
Ah I just remembered, we had the same problem while following the same guide!
b

Bailey Pollard

06/16/2021, 2:31 PM
What did you do differently?
t

Tiago Nunes

06/16/2021, 2:31 PM
You're probably missing this line:
podfile = project.file(*"../iosApp/Podfile")*
Inside the cocoapods DSL
b

Bailey Pollard

06/16/2021, 2:31 PM
how is that Podfile created?
manually?
t

Tiago Nunes

06/16/2021, 2:32 PM
Yes, but it should've been generated by the KMM plugin wizard
b

Bailey Pollard

06/16/2021, 2:32 PM
Nope, only have kotlin, resources in my iosMain directory
t

Tiago Nunes

06/16/2021, 2:33 PM
Not iosMain, iosApp, my bad
b

Bailey Pollard

06/16/2021, 2:33 PM
We don't have an iosApp dir on any of our Kotlin MP projects 🤔
t

Tiago Nunes

06/16/2021, 2:35 PM
Right, you're building a KMM library... so when are you running into this error?
b

Bailey Pollard

06/16/2021, 2:36 PM
This error happens when I add pod("...") into the build.gradle file and try to do a gradle sync
Can you even add pod dependancies to KMM libraries?
t

Tiago Nunes

06/16/2021, 2:37 PM
Hm... I'm running out of ideas. Have you installed cocoapods-generate?
b

Bailey Pollard

06/16/2021, 2:38 PM
I've installed it into my command line, is there anything further that I need to do?
pod gen
executes
t

Tiago Nunes

06/16/2021, 2:42 PM
Have you tried this:
Copy code
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
   if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
       ::iosArm64
   else
       ::iosX64

iosTarget("ios") {}
instead of:
Copy code
ios()
Also, if you're importing a local pod dependency, the docs are wrong. Instead of:
Copy code
source = path(project.file("../pod_dependency/pod_dependency.podspec"))
should be:
Copy code
source = path(project.file("../pod_dependency"))
b

Bailey Pollard

06/16/2021, 2:47 PM
This is what I have to fetch the pod
t

Tiago Nunes

06/16/2021, 2:50 PM
Well, I don't think I can help you... maybe our current problem is somehow related, when we figure it out we'll let you know, and if you could do the same that'd be great. Best of luck 🙂
b

Bailey Pollard

06/16/2021, 2:50 PM
Thanks for the ideas! I appreciate it
t

Tiago Nunes

06/16/2021, 5:21 PM
We found our problem, but unfortunately it probably doesn't apply to you
b

Bailey Pollard

06/16/2021, 5:22 PM
😞
t

Tiago Nunes

06/16/2021, 5:39 PM
I'll explain my problem better in my thread tomorrow, but basically we were including our KMM library project in settings.gradle of the app project, and then using implement(project(":library")). This way of importing projects doesn't seem to be supported for KMM projects. When building for iOS it would try to build the KMM project and would skip some important tasks.
This is kind of what's supposed to happen: library:genDefFile library:genDummyFramework library:downloadPods ... library:cinteropsLibraryIos This is what was happening: library:genDefFile library:cinteropsLibraryIos And it would fail in this task, because it didn't generate the frameworks before trying to compile to Kotlin (or something of that nature)
We fixed by using maven publish plugin and importing via maven
b

Bailey Pollard

06/16/2021, 8:40 PM
@Tiago Nunes should i be using a certain java version?
Cloned this repo, and getting the same errors https://github.com/Kotlin/kotlin-with-cocoapods-sample
t

Tiago Nunes

06/16/2021, 11:30 PM
Im using Java 16.0.1. I think that Java 16 only works with Gradle 7+ and AGP 7+
But that shouldn't be the issue. Tomorrow I'll try cloning that repo
b

Bailey Pollard

06/16/2021, 11:51 PM
Does this only work with objc?
Like the pod your importing has to be objc, not swift?
t

Tiago Nunes

06/17/2021, 8:08 AM
Pure swift modules aren't supported yet. But if you have a swift project with some @objc annotations, those are exported
b

Bailey Pollard

06/17/2021, 1:17 PM
@Tiago Nunes Would you be able to do me a huge favour and try to import
Copy code
pod("StarIO") {
version = "~> 2.8.2"
}
I managed to get the sample project to work with AFNetworking, but StarIO is still giving that error 🤔
t

Tiago Nunes

06/17/2021, 1:31 PM
Unfortunately my VM ran out of space today, I'm fighting with my boss to buy macs for our team
3 Views