opkmag.blogg.se

Kotlin multiplatform ios example
Kotlin multiplatform ios example










kotlin multiplatform ios example kotlin multiplatform ios example

Now you can easily link shared code with your main project, just add this line of code inside you android.app module. Here you could find all the information about gradle plugin configurations and supported platforms Ĥ) And that’s it, you are ready to go. To make it work you need to change Shared adle file apply plugin: 'kotlin-multiplatform' kotlin

  • Inside src folder create commonMain and androidMain folders and create kotlin folder inside each.ģ.
  • File->New->New module->Java module->name is “Shared”.
  • UPDATE: For MPM you have to use the latest kotlin plugin (1.3+), you could check it Tools->Kotlin-Configure Kotlin Plugin Updates We’ll use Android Studio to create a new MPM (multiplatform module)
  • Create it from Android Studio (Currently is not supported, but you can create a java-library project and refactor it mannually to be MPM).
  • Do everything manually (It sounds scary, but nothing to be afraid about).
  • kotlin multiplatform ios example

    Create a new multiplatform-project throught IntelliJ IDEA.

    kotlin multiplatform ios example

    You can find more details here Įxpected is inside the commonMain package import expect val ApplicationDispatcher: CoroutineDispatcherĪctual is inside the androidMain (iOSMain, jsMain etc…) package import import actual val ApplicationDispatcher: CoroutineDispatcher = Dispatchers.IO Kotlin multiplatform introduced two new keywords: expect and actualĮxpected is used inside the commonMain to notify the compiler that shared part of your code requires some platform-specific implementation, while actual is the way of telling the compiler that you have provided a platform specific implementation and shared module is ready to go. This is the only sourceSet that would be available from all existing platforms, basically, all shared logic will be here. Every sourceSet folder is separated from the others except commonMain.












    Kotlin multiplatform ios example