Issue
I'm developing the Kotlin Multiplatform Library, already written the androidMain
, commonMain
and iosMain
. Now to test the written code on actual android and ios device I have added example package inside the root folder and created the new KMP project inside it where I can be able to showcase the my KMP library usage to community.
To link the example project with my library I've added below lines in library settings.gradle.kts
file :
include(":example:kmp:androidApp")
include(":example:kmp:iosApp")
include(":example:kmp:shared")
After syncing the project I can see the androidApp
run configuration to run and test the library code on device but not able to see iosApp
run configuration to run the app on ios device.
Any help or lead will be appreciated.
Solution
First thing, you should not be able to see the iosApp
configuration and run from Android Studio unless you have the Kotlin Multiplatform Mobile Plugin installed in your IDE. So make sure you have the correct compatible version installed.
Second thing is generally we add a new Multiplatform library module in an existing KMM project. We add the library functionality in this new module. Then we add the library module to the example project to demonstrate. You can do this by adding this to your example build.gradle.kts
file (replace library
with your library module name):
implementation(project(":library"))
So basically the KMP shared module of the example project and the library KMP module stays in the same hierarchy level with the root directory of the project. In your case, you created an example
directory inside which the sample KMP project has been added. That might be the reason why Android Studio is unable to find the run configuration for iosApp.
You can try creating an iosApp run configuration manually (considering you have the KMM plugin installed) from Run/Debug Configurations
dialog of Studio. Make sure the Xcode project file
is pointing to: ../iosApp/iosApp.xcodeproj
file of your sample or example project. Also enter the other details like project scheme
, configuration
and execution target
.
Also in the settings.gradle.kts
file, you can just add (assuming your example and library modules are in the project root):
include(":example")
include(":library")
Answered By - Carshtokky
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.