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

Mikołaj Karwowski

05/26/2021, 4:51 PM
[KMM/iOS/Cocoapods] Has anyone had any luck with usage of cocoapods in iOS part of KMM library? I think I check most of the possible threads on SO/youtrack/samples etc, but can't get Amplify library to work Inside the iOS (tried iosx64 etc also as suggested in some ticket about that) module I can import the cocoapods.Amplify.* but all I see is 3 Double values from it and no classes that should be present in the Amplify library (checked it first on a native ios project using same pods) If any of You uses the cocoapods inside KMM, how do You do it? Could anyone help me with getting it to at least call Amplify.configure() from within the ios module of shared library? Including a simple project that represents my problem in iosMain/Platform.kt: https://github.com/Bezkarpie/KMMcocopods Thanks! : )
m

Mayank

05/26/2021, 7:05 PM
Looks like Amplify does not support Objective-C and using pure Swift modules are not yet supported by KMM.
You can create a pod containing Swift wrapper class with all the functionality needed, export objc headers for that and use that in KMM. Its not ideal but might work for you. Another approach could be to create an interface in KMM, have an implementation in ios project and inject it where required.
m

Mikołaj Karwowski

05/26/2021, 7:51 PM
Ah, thank You so much! I was banging my head against the wall and now I know why it's not working. I already handled it with the interface but it was so ugly that I couldn't stand it :P
👍 1
3 Views