Publish your application
Once your apps are ready for release, it's time to deliver them to the users by publishing them.
For mobile apps, multiple stores are available for each platform. However, in this article, we'll focus on the official ones: Google Play Store and Apple App Store. For web apps, we'll use GitHub pages.
You'll learn how to prepare Kotlin Multiplatform applications for publishing, and we'll highlight the parts of this process that deserve special attention.
Android app
Since Kotlin is the main language for Android development, Kotlin Multiplatform has no obvious effect on compiling the project and building the Android app. Both the Android library produced from the shared module and the Android app itself are typical Android Gradle modules; they are no different from other Android libraries and apps. Thus, publishing the Android app from a Kotlin Multiplatform project is no different from the usual process described in the Android developer documentation.
iOS app
The iOS app from a Kotlin Multiplatform project is built from a typical Xcode project, so the main stages involved in publishing it are the same as described in the iOS developer documentation.
What is specific to Kotlin Multiplatform projects is compiling the shared Kotlin module into a framework and linking it to the Xcode project. Generally, integration between the shared module and the Xcode project is done automatically by the Kotlin Multiplatform plugin for Android Studio. However, if you don't use the plugin, bear in mind the following when building and bundling the iOS project in Xcode:
The shared Kotlin library compiles down to the native framework.
You need to connect the framework compiled for the specific platform to the iOS app project.
In the Xcode project settings, specify the path to the framework to search for the build system.
After building the project, you should launch and test the app to make sure that there are no issues when working with the framework in runtime.
There are two ways you can connect the shared Kotlin module to the iOS project:
Use the Kotlin/Native CocoaPods plugin, which allows you to use a multiplatform project with native targets as a CocoaPods dependency in your iOS project.
Manually configure your Multiplatform project to create an iOS framework and the Xcode project to obtain its latest version. The Kotlin Multiplatform wizard or Kotlin Multiplatform plugin for Android Studio usually does this configuration. See Connect the framework to your iOS project to learn how to add the framework directly in Xcode.
Configure your iOS application
You can configure basic properties that affect the resulting app without Xcode.
Bundle ID
The bundle ID uniquely identifies your app in the operating system. To change it, open the iosApp/Configuration/Config.xcconfig
file in Android Studio and update the BUNDLE_ID
.
App name
The app name sets the target executable and application bundle name. To change your app name:
If you have not opened the project in Android Studio yet, you can change the
APP_NAME
option in theiosApp/Configuration/Config.xcconfig
file directly in any text editor.If you've already opened the project in Android Studio, do the following:
Close the project.
In any text editor, change the
APP_NAME
option in theiosApp/Configuration/Config.xcconfig
file.Re-open the project in Android Studio.
If you need to configure other settings, use Xcode: after opening the project in Android Studio, open the iosApp/iosApp.xcworkspace
file in Xcode and make changes there.
Symbolicating crash reports
To help developers make their apps better, iOS provides a means for analyzing app crashes. For detailed crash analysis, it uses special debug symbol (.dSYM
) files that match memory addresses in crash reports with locations in the source code, such as functions or line numbers.
By default, the release versions of iOS frameworks produced from the shared Kotlin module have an accompanying .dSYM
file. This helps you analyze crashes that happen in the shared module's code.
When an iOS app is rebuilt from bitcode, its dSYM
file becomes invalid. For such cases, you can compile the shared module to a static framework that stores the debug information inside itself. For instructions on setting up crash report symbolication in binaries produced from Kotlin modules, see the Kotlin/Native documentation.
Web app
To publish your web application, create the artifacts containing the compiled files and resources that make up your application. These artifacts are necessary to deploy your application to a web hosting platform like GitHub Pages.
Generate artifacts
Create a run configuration for running the wasmJsBrowserDistribution task:
Select the Run | Edit Configurations menu item.
Click the plus button and choose Gradle from the dropdown list.
In the Tasks and arguments field, paste this command:
wasmJsBrowserDistributionClick OK.
Now, you can use this configuration to run the task:
Once the task completes, you can find the generated artifacts in the composeApp/build/dist/wasmJs/productionExecutable
directory:
Publish your application on GitHub Pages
With the artifacts ready, you can deploy your application on the web hosting platform:
Copy the contents of your
productionExecutable
directory into the repository where you want to create a site.Follow GitHub's instructions for creating your site.
In a browser, navigate to your GitHub pages domain.
Congratulations! You have published your artifacts on GitHub pages.
Debug your web application
You can debug your web application in your browser out of the box, without additional configurations. To learn how to debug in the browser, see the Debug in your browser guide in Kotlin docs.