This guide will help you set up your development environment for working on the react-native-mparticle SDK.
- Node.js and npm
- React Native development environment set up (React Native Environment Setup Guide)
- For iOS:
- macOS
- Xcode (latest version recommended)
- CocoaPods
- Ruby (for CocoaPods)
- For Android:
- Android Studio
- Java Development Kit (JDK)
- Android SDK
react-native-mparticle/
├── android/ # Native Android SDK implementation
├── ios/ # Native iOS SDK implementation
├── js/ # JavaScript/TypeScript SDK implementation
├── plugin/ # Expo config plugin source
│ └── src/ # Plugin TypeScript source files
├── sample/ # Sample app for testing (manual RN setup)
├── ExpoTestApp/ # Expo test app for testing config plugin
└── ...
Install dependencies:
yarn installThe sample app is a great way to test your changes and see the SDK in action.
- Navigate to the sample directory:
cd sample- Install dependencies (iOS pods are installed automatically via postinstall):
yarn install- Start the Metro bundler:
yarn start- Open the iOS workspace:
open ios/MParticleSample.xcworkspace- In Xcode:
- Select your target device/simulator
- Update signing configuration if needed
- Build and run (⌘R)
- Navigate to the sample directory:
cd sample- Install JavaScript dependencies:
npm install
# or
yarn install- Start the Metro bundler:
npm start
# or
yarn start-
Open Android Studio:
- Open the
androidfolder in Android Studio - Let Gradle sync complete
- Update any required SDK packages if prompted
- Open the
-
Run the app:
- Select your target device/emulator
- Click Run (or press ⇧F10)
The ExpoTestApp is used for testing the Expo config plugin integration.
- Build and pack the main library:
# From the root directory
yarn dev:pack- Navigate to the ExpoTestApp:
cd ExpoTestApp- Install dependencies:
npm install- Update API keys in
app.json(plugins section):
{
"expo": {
"plugins": [
[
"react-native-mparticle",
{
"iosApiKey": "YOUR_IOS_API_KEY",
"iosApiSecret": "YOUR_IOS_API_SECRET",
"androidApiKey": "YOUR_ANDROID_API_KEY",
"androidApiSecret": "YOUR_ANDROID_API_SECRET"
}
]
]
}
}- Run prebuild to generate native projects:
npm run prebuild- Run the app:
# iOS
npm run ios
# Android
npm run androidAfter prebuild, verify the plugin configured the native projects correctly:
iOS (ios/<AppName>/AppDelegate.swift):
- Check for
import mParticle_Apple_SDK - Check for
MParticleOptionsinitialization indidFinishLaunchingWithOptions
Android (android/app/src/main/java/.../MainApplication.kt):
- Check for mParticle imports
- Check for
MParticleOptionsinitialization inonCreate()
When making changes to the Expo plugin:
# From the root directory
yarn build:plugin
yarn dev:pack
# From ExpoTestApp directory
rm -rf node_modules ios android
npm install
npm run prebuildyarn buildyarn build:pluginyarn dev:packThis creates react-native-mparticle-latest.tgz which can be used for local testing in the ExpoTestApp or other projects.
cd android
./gradlew buildcd ios
pod install# Run JavaScript tests
npm test
# Run Android tests
cd android
./gradlew test
# Run iOS tests
cd ios/RNMParticle.xcodeproj
xcodebuild test-
"Missing config.h" error: This error occurs because the mParticle SDK contains Swift code which requires special handling. To fix this:
a. Open your
sample/ios/Podfileand add this block before the target definition:pre_install do |installer| installer.pod_targets.each do |pod| if pod.name == 'mParticle-Apple-SDK' def pod.build_type; Pod::BuildType.new(:linkage => :dynamic, :packaging => :framework) end end end end
b. Clean and reinstall pods:
cd sample/ios pod cache clean --all rm -rf Pods Podfile.lock pod installc. If using Xcode 12 or later, ensure your project's Build Settings has "Allow Non-modular Includes In Framework Modules" set to Yes
-
Pod install fails:
- Try cleaning the pod cache:
pod cache clean --all - Delete Podfile.lock and try again
- Ensure CocoaPods is up to date:
bundle update
- Try cleaning the pod cache:
-
Build errors:
- Clean build folder in Xcode (⇧⌘K)
- Delete derived data:
rm -rf ~/Library/Developer/Xcode/DerivedData - Ensure all dependencies are properly installed
-
Gradle sync fails:
- Check Android Studio SDK Manager for missing packages
- Update Gradle version if needed
- Clean project and rebuild
-
Build errors:
- Run
./gradlew clean - Invalidate caches in Android Studio
- Ensure all dependencies are properly installed
- Run
- Create a feature branch
- Make your changes
- Test thoroughly
- Create a pull request
- Ensure CI passes
- Request review
-
Update version numbers:
- package.json
- android/build.gradle
- ios/RNMParticle.podspec
-
Update CHANGELOG.md
-
Create release PR
-
After merge, create a new release on GitHub
-
Publish to npm:
npm publish