We welcome contributions! This guide will help you get started with development setup and understanding the project structure.
-
Clone and Install Dependencies
git clone https://github.com/hyodotdev/openiap.git cd openiap/libraries/react-native-iap yarn install -
Generate Nitro Files
yarn specs
-
Running the Example App
cd example && yarn ios cd example && yarn android
This project includes one React Native CLI example application:
- Location:
example/screens/ - Router: React Navigation
- Package Manager: Yarn (workspace)
- Purpose: Main development and testing environment
- Run
yarn typecheckandyarn lint --fixbefore committing - Use TypeScript with strict mode
- Follow existing code style and conventions
- Add tests for new features when possible
When working with example screens:
- Modify Source Files: Make changes in
example/screens/*.tsx - Test React Native: Run
cd example && yarn ios/androidto test changes - Commit: Commit the source files in
example/screens/
Before submitting changes:
# Check TypeScript and linting
yarn typecheck && yarn lint --fix
# Run library tests
yarn test:ci
# Test example apps
cd example && yarn testFollow these steps when preparing a new release (e.g., 14.2.0):
-
Verify CI locally
yarn ci:check # or: yarn typecheck && yarn lint --fix && yarn test:ci && yarn nitrogen
-
iOS/OpenIAP
- Ensure Nitro codegen is up to date:
yarn nitrogen - Verify Pods resolve in the example app:
cd example/ios && pod install
- Ensure Nitro codegen is up to date:
-
Android
- We ship consumer R8 keep rules in
android/consumer-rules.proso Nitro classes aren’t stripped. - Verify a release build of the example app:
cd example/android && ./gradlew :app:assembleRelease
- We ship consumer R8 keep rules in
-
Version bump & docs
- Update
package.jsonversion - Add a blog post in
docs/blog/with highlights - Update CHANGELOG if needed
- Update
-
Tagging and Publishing
- Push the release PR; ensure CI is green
- Create a GitHub Release
- Publish to npm via the existing workflows
android/: All yourandroid-specific implementations.build.gradle: The gradle build file. This contains four important pieces:- Standard react-native library boilerplate code
- Configures Kotlin (
apply plugin: 'org.jetbrains.kotlin.android') - Adds all Nitrogen files (
apply from: '.../NitroIap+autolinking.gradle') - Triggers the native C++ build (via CMake/
externalNativeBuild)
CMakeLists.txt: The CMake build file to build C++ code. This contains four important pieces:- Creates a library called
NitroIap(same as innitro.json) - Adds all Nitrogen files (
include(.../NitroIap+autolinking.cmake)) - Adds all custom C++ files (only
HybridTestObjectCpp.cpp) - Adds a
cpp-adapter.cppfile, which autolinks all C++ HybridObjects (onlyHybridTestObjectCpp)
- Creates a library called
src/main/java/com/margelo/nitro/iap/: All Kotlin implementations.NitroIapPackage.java: The react-native package. You need this because the react-native CLI only adds libraries if they have a*Package.javafile. In here, you can autolink all Kotlin HybridObjects.
cpp/: All your cross-platform implementations. (onlyHybridTestObjectCpp.cpp)ios/: All your iOS-specific implementations.nitrogen/: All files generated by nitrogen. You should commit this folder to git.src/: The TypeScript codebase. This defines all HybridObjects and loads them at runtime.specs/: All HybridObject types. Nitrogen will run on all*.nitro.tsfiles.
nitro.json: The configuration file for nitrogen. This will define all native namespaces, as well as the library name.NitroIap.podspec: The iOS podspec build file to build the iOS code. This contains three important pieces:- Specifies the Pod's name. This must be identical to the name specified in
nitro.json. - Adds all of your
.swiftor.cppfiles (implementations). - Adds all Nitrogen files (
add_nitrogen_files(s))
- Specifies the Pod's name. This must be identical to the name specified in
package.json: The npm package.json file.react-native-nitro-modulesshould be apeerDependency.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting:
yarn typecheck && yarn lint --fix - Submit a pull request with a clear description
For detailed usage examples and error handling, see the documentation.