Contained in: Kotlin Multiplatform by Tutorials
objective c
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Connecting to Platform-Specific API
May 7 2025 · Chapter
…encounter in this book. But don’t worry: KMP isn’t usually like this. It’s here to demonstrate where things can become intricate. Objective-C at its core is C. In C, Structures (also called structs) are a way to group several related variables into one place. Practically, whenever…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Creating Your KMP Library
May 7 2025 · Chapter
…this code to Kotlin and find the corresponding iOS functions. It’s important to remember that although you’re writing Swift code, KMP uses Objective-C signatures. This is why you use the NSLog on the PlatformLogger.kt file from shared/iosMain. Occasionally, it can be difficult to find the module…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Dependency Injection
May 7 2025 · Chapter
Android app after integrating Koin. iOS Koin is a Kotlin library. Lots of bridging occurs, should you want to use it with Swift and Objective-C files and classes. To make things easier, you’d better create some helper classes and functions. Create KoinIOS.kt inside the iosMain directory…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Introduction
May 7 2025 · Chapter
…press Control and click to jump to its definition. Fig. 1.16 — Xcode method definition This will open the shared.h file. It’s written in Objective-C, but it allows you to use all the code from the shared project. Scroll to the bottom of the file and you will…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Data Persistence
May 7 2025 · Chapter
…initialize method on KoinIOS object. You can add a parameter to that method, so you can inject an instance of UserDefaults — or, in Objective-C nomenclature, NSUserDefaults. Make the following changes to the initialize function: fun initialize( userDefaults: NSUserDefaults, ): KoinApplication = initKoin( appModule = module { single<Settings> { NSUserDefaultsSettings(userDefaults…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Concurrency
May 7 2025 · Chapter
…defines the scope to use, and allows you to have more control over it. @NativeCoroutines: functions that use this are not generated for Objective-C, but instead, an extension is created that can more easily be accessed from Swift. This is generated via the KSP plugin that you just added…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Appendix A: Kotlin: A Primer for Swift Developers
May 7 2025 · Chapter
…with the same one — this convention guarantees there is no conflict between apps from different companies. Every time you declare a new class or object, you must define the package declaration. This should be the first instruction of a new file. Or, if you have a copyright header, right after…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
App Architecture
May 7 2025 · Chapter
…more and more. Additionally, Apple introduced the Observation framework in iOS 17 to simplify the utilization of this pattern. Clean Architecture In 2012, Robert C. Martin, also known as Uncle Bob, published a post in his blog at https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html explaining the details of a new design pattern…
Android & Kotlin
Chapter in Kotlin Multiplatform by Tutorials
Appendix C: Sharing Your Compose UI Across Multiple Platforms
May 7 2025 · Chapter
Compose Multiplatform To follow along with the code examples throughout this appendix, download the project and open 17-appendix-c-sharing-your-compose-ui-across-multiple-platforms/projects/starter with Android Studio. starter is the challenge 1 version of learn from Chapter 14 with the only difference that the shared modules…