Hey folks, currently in the process of following <...
# multiplatform
b
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
May be related to https://youtrack.jetbrains.com/issue/KT-44155 Try calling useLibraies() in cocoapods block
t
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
@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
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
Yes
Do I have to rename my iosMain dir to something else?
t
Ah I just remembered, we had the same problem while following the same guide!
b
What did you do differently?
t
You're probably missing this line:
podfile = project.file(*"../iosApp/Podfile")*
Inside the cocoapods DSL
b
how is that Podfile created?
manually?
t
Yes, but it should've been generated by the KMM plugin wizard
b
Nope, only have kotlin, resources in my iosMain directory
t
Not iosMain, iosApp, my bad
b
We don't have an iosApp dir on any of our Kotlin MP projects 🤔
t
Right, you're building a KMM library... so when are you running into this error?
b
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
Hm... I'm running out of ideas. Have you installed cocoapods-generate?
b
I've installed it into my command line, is there anything further that I need to do?
pod gen
executes
t
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
This is what I have to fetch the pod
t
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
Thanks for the ideas! I appreciate it
t
We found our problem, but unfortunately it probably doesn't apply to you
b
😞
t
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
@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
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
Does this only work with objc?
Like the pod your importing has to be objc, not swift?
t
Pure swift modules aren't supported yet. But if you have a swift project with some @objc annotations, those are exported
b
@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
Unfortunately my VM ran out of space today, I'm fighting with my boss to buy macs for our team