Global helper for initializing and building Kotlin-based native modules for React Native
- Android Studio 3.1 or later
- React Native 0.56.0 or newer (have not tested lower than that)
react-native-kotlin-cli is a helper utility for initializing new Kotlin-based native modules and UI components.
yarn global add react-native-kotlin-cli
To learn how it works:
react-native-kotlin --help
_react-native-kotlin lets you quickly create a new kotlin-based native module and get coding.
react-native-kotlin init myproject
This comes with scripts now!
Automatically build the bridge file from Kotlin to React-Native. Uses react-native-kotlin-bridge for the building work - check that out for idiosyncracies.
Will watch your kt files (in the module) for changes, and rebuild your JS on the fly. Super-handy. Best practice is to run as background process so as not to lock up a terminal:
yarn watch &
Don't develop native code from your module. Never works well. Best practice is to work from the context of a runnable app.
react-native-kotlin
makes it easy to create a new almost-blank react-native app and add your kotlin module.
react-native-kotlin makeapp myprojecttest myproject
You can add the Swift-based native module to you app relatively easily.
cd /path/to/myapp
yarn add link:/path/to/myproject # local link
# yarn add @me/myproject # npm registered
# yarn add meongithub/myproject # github fetch
yarn add react-native-update-gradle # You probably need to add this to allow kotlin support
yarn add react-native-fix-android-links # Guarantees your devex if you deploy via a link
react-native link
The react-native-kotlin package will, via react-native link, take care of compatibility between your react native and the Kotlin based component.
Done!