Hello World in Kotlin Multiplatform Mobile (new empty project)
Kotlinlang.org hass instructions on getting you all setup from scratch; they can be found here.
Up to date instructions on how to configure your environment for KMM can be found on the KMM website.
If you are a more visual learner, the Kotlin team published a good video tutorial on YouTube titled, "Your First Kotlin Multiplatform Mobile App Tutorial"
.
Alternatively, the TL;DR:
- Install the latest Android Studio for your platform.
- Install the latest Kotlin Multiplatform Mobile plugin.
- Download the latest Xcode.
- Install cocoapods:
sudo gem install cocoapods
- Create a new KMM project, or clone this repository.
git clone https://github.com/BlakeBarrett/HelloKMM.git
- Its always good practice to add a good
.gitignore
file to any new repository.
I used gitignore.io to generate the ignore files in this repository.
Seeing this?
'pod install' command failed with an exception:
Cannot run program "pod" (in directory "/Users/svprdga/code/personal/kmm/Test/ios"): error=2, No such file or directory
Possible reason: CocoaPods is not installed
Please check that CocoaPods v1.10 or above and cocoapods-generate plugin are installed.
To check CocoaPods version type 'pod --version' in the terminal
To install CocoaPods execute 'sudo gem install cocoapods'
To install cocoapod-generate execute 'sudo gem install cocoapods-generate'
There is an issue when building the project sometimes it will tell you the cocoapods is not installed when it, in fact, very much is -- this is not your problem, this is a permissions issue in Android Studio that JetBrains is aware of. Lucky for us, there is a simple enough fix/resolution.
- Launch a terminal and execute the following command
chmod +x /Applications/Android\ Studio.app/Contents/bin/printenv