To use the Ktor HTTP client in your project, you need to add at least two dependencies: a client dependency and an engine dependency. To view the complete structure of the generated multiplatform project, switch from Android to Project in a Project view.Ĭonfigure build scripts Add Ktor dependencies It may take some time to download and set up the required components when you do this for the first time. On the next page, leave the default settings and click Finish to create a new project. In our tutorial, the application name is KmmKtor. Specify a name for your application, and click Next. Select Kotlin Multiplatform App in the list of project templates, and click Next. In Android Studio, select File | New | New Project. You will need a Mac with macOS to complete certain steps in this tutorial, which include writing iOS-specific code and running an iOS application.
#KOTLIN KLIB HOW TO#
Learn how to do this from the Set up an environment section. Prerequisitesįirst, you need to set up an environment for cross-platform mobile development by installing the necessary tools on a suitable operating system. There was a separate plugin for that last year, but you definitely don't want to be using that. Konan is the name of the native platform/compiler. In Link 2 it says that platform plugin is deprecated. If you're building a klib separately, you're creating some extra steps (probably). To learn how to create your first Kotlin Multiplatform Mobile application, see Create your first cross-platform mobile app. In general, you'll want to use the multiplatform plugin.
![kotlin klib kotlin klib](https://ask.qcloudimg.com/http-save/yehe-5426717/c57a7bff2f3f2f0bf8c306274e966612.png)
![kotlin klib kotlin klib](https://www.homedt.net/wp-content/uploads/2022/08/aa103c059bf842cd0d13ffab4d9a8797.jpg)
In this tutorial, we'll create a simple Kotlin Multiplatform Mobile application, which sends a request and receives a response body as plain HTML text.
![kotlin klib kotlin klib](https://files.speakerdeck.com/presentations/2419536305ae41f89b7c8921f5952d69/slide_37.jpg)
The Ktor HTTP client can be used in multiplatform projects. Creating a cross-platform mobile application