https://kotlinlang.org/docs/multiplatform-get-started.html
https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-create-first-app.html
Set up Environment:
Check Environment:
- brew install kdoctor
- kdoctor
Install brew if necessary, brew.sh
There could be various issues:
Environment diagnose (to see all details, use -v option):
[✓] Operation System
[✖] Java
✖ Java not found
Get JDK from https://www.oracle.com/java/technologies/javase-downloads.html
[!] Android Studio
! Android Studio (AI-233.14808.21.2331.11842104)
Location: /Applications/Android Studio.app
Bundled Java: openjdk 17.0.10 2024-01-16
Kotlin Plugin: 233.14808.21.2331.11842104-AS
Kotlin Multiplatform Mobile Plugin: not installed
Install Kotlin Multiplatform Mobile plugin - https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile
[✖] Xcode
✖ Xcode requires to perform the First Launch tasks
Launch Xcode and complete setup
[!] CocoaPods
! CocoaPods configuration is not required, but highly recommended for full-fledged development
✖ cocoapods not found
Get cocoapods from https://guides.cocoapods.org/using/getting-started.html#installation
Conclusion:
✖ KDoctor has diagnosed one or more problems while checking your environment.
Please check the output for problem description and possible solutions.
Solutions:
1. Java Not Found
Problem: The Java Development Kit (JDK) is missing.
Solution: Install the JDK by downloading it from the official Oracle website or via Homebrew:
For macOS, you can also use Homebrew:
brew install openjdk@11
2. Android Studio
Problem: Kotlin Multiplatform Mobile Plugin is not installed.
Solution: Install the Kotlin Multiplatform Mobile plugin.
- In Android Studio, go to Preferences > Plugins, search for “Kotlin Multiplatform Mobile,” and install it.
3. Xcode First Launch Setup
Problem: Xcode needs to complete First Launch tasks.
Solution: Open Xcode and allow it to perform its first-time setup. You can launch Xcode with this command:
open /Applications/Xcode.app
4. CocoaPods Not Found
Problem: CocoaPods is not installed.
Solution: Install CocoaPods using the following command:
sudo gem install cocoapods
After installation, verify it by running:
pod --version
Final Steps
After performing these steps, rerun kdoctor
to ensure everything is set up correctly:
kdoctor