Create first multiplatform application – tutorial

Tram Ho

KMM: Kotlin Multiplatform. Here, we will learn how to create and run our first KMM application.

Project initialization

1.Set up your environment for KMM development by installing necessary tools on a suitable operating system

You’ll need a Mac with macOS to complete certain steps in this tutorial, including writing iOS-specific code and running iOS apps. These steps cannot be performed on other operating systems, such as Microsoft Windows. This is due to a request from Apple.

2 In Android Studio, select File | New | New Project.

3. Select KMM from the list of project templates and click Next.

4. Specify a name for your first application and click Next.

5.Keep the default names for your apps and shared folders, check the checkbox to create sample trials for your project and click Finish.

Now, wait while your project is up and running. It may take some time to download and set up the required components when you do this for the first time. To see the complete structure of your mobile cross-platform project, switch the view from Android to Project. You can understand KMM project structure and how you can use this structure.

Update your application

1 Open the Greeting.kt file in shared / src / commonMain / kotlin / com.example.kmmapplication.shared. This folder stores code shared for both platforms – Android and iOS. If you make changes to the shared code, you’ll see the changes in both apps.

2.Update shared code – using Kotlin standard library functionality that works on all platforms: reversed ()

3.Run the updated application

Next step

Once you get started with your first KMM application, you can:

Understand the KMM project structure. Complete hands-on networking and data storage. Complete tutorial on how to make your Android apps work on iOS.

Reference article:

Share the news now

Source : Viblo