https://kotlinlang.org logo
Title
h

Hasan Nagizade

04/29/2023, 11:03 AM
Hi there. How can I call Cocoapods library from iOSMain common code? I want to write a wrapper for socket io using expect/actual and just don't know how to import iOS side Socket IO dependency into Kotlin code
m

mohamed rejeb

04/29/2023, 1:23 PM
h

Hasan Nagizade

05/01/2023, 4:23 AM
I have seen that link. It's not really helping
Screenshot 2023-05-01 at 08.25.50.png
a

a-dd

05/02/2023, 8:57 AM
Is a gradle sync successful in your case? Are there any warnings or errors?
h

Hasan Nagizade

05/02/2023, 9:01 AM
Gradle sync is successful but cocoapods import is not available
a

a-dd

05/02/2023, 9:02 AM
Can you share the build script or maybe the full project?
h

Hasan Nagizade

05/02/2023, 9:03 AM
you mean build.gradle file?
a

a-dd

05/02/2023, 9:03 AM
Yes
h

Hasan Nagizade

05/02/2023, 9:04 AM
sure. sharing files right now. here's my podfile.
this is shared build.gradle file
root build.gradle file.
is there any other file that you need?
kotlin.mpp.enableCInteropCommonization=true
is enabled in
gradle.properties
file
a

a-dd

05/02/2023, 9:29 AM
You should add pod-dependency to cocoapods block of the build.gradle not to the podfile
h

Hasan Nagizade

05/02/2023, 9:33 AM
just added but no luck. still cocoapods can't be linked from iOSMain
a

a-dd

05/02/2023, 9:37 AM
And still no warnings/errors during sync?
h

Hasan Nagizade

05/02/2023, 9:41 AM
only this nothing else
a

a-dd

05/02/2023, 10:05 AM
There should be smth like
fatal error: module 'Socket' not found
This can be fixed by adding
moduleName
to the dependency declaration, like this:
pod("Socket.IO-Client-Swift", version = "15.2.0", moduleName = "SocketIO")
h

Hasan Nagizade

05/02/2023, 10:09 AM
there isn't any errors but after adding module name it became visible with semi/autocompletition.
I consider this as a win thank you @a-dd