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

Tony N

02/27/2024, 10:45 PM
Hey all! We have an existing Android and iOS project and I am working on creating a KMP library to be shared between both. Right now I went with creating the KMP module inside our existing Android project. This is great because any new changes to the KMP project can be tested right away in our Android project by just rebuilding. Would you guy happen to know a way to make the iOS process just as simple? Currently I am using CocoaPods to integrate the KMP library into our iOS project. But this process can take some time since I would have to run podPublishXCFramework gradle task to create the Framework, then pod update on the iOS project.
s

Sharyl

02/28/2024, 12:33 AM
I started a project from scratch and have the ios app, android app and shared KMP library all in the same repository. I can build both iOS and Android from android studio. I did not use cocoapods for iOS and currently don't have any pods in it. I do still often run the iOS app directly from Xcode.
1
t

Tony N

02/28/2024, 2:11 PM
Gotcha! At the moment that may not be feasible for us since we already have a large existing Android and iOS project. Not sure if it would be possible to move our whole iOS project into our Android one.
s

Sharyl

02/28/2024, 8:50 PM
You don't HAVE to build the iOS KMP library as a cocoapod, even if you already have other pods. Then you could just move the framework to the ios build location needed instead of having to run cocoapods. That would be a time/hassle saver. Look at the setup options for KMP as a library shared between two apps. The framework get's built and added to shared/build/xcode-frameworks/ You could build both through android studio, then do a quick move/copy of the iOS framework. Then rebuild iOS from xcode. Not as simple as 1 repo, but much easier than messing with Cocoapods.
t

Tony N

02/28/2024, 9:05 PM
Would we still have to run a gradle task to create the xcode framework?
s

Sharyl

02/28/2024, 10:18 PM
yes
My setup was built in when I created the KMP project, so it's easy ... I just switch my configuration in Android Studio to build/run iOSApp. It builds the framework and starts my iOS app in the simulator. I use a mac. It's important to me that building is very simple right now. I am one person writing both apps and I don't have a lot of time to spend on devops.
When a new KMP project is created it creates 3 main folders. iosApp, androidApp and shared. If you wanted to restructure, you could move your iOS app to the iosApp folder in the same repo. It would save you a lot of build time. I know I can build both apps and test a change to the shared KMP library in under 2 minutes.
4 Views