|
| 1 | +# Developer Onboarding Guide |
| 2 | + |
| 3 | +This guide will help you set up your development environment for working on the react-native-mparticle SDK. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Node.js and npm |
| 8 | +- React Native development environment set up ([React Native Environment Setup Guide](https://reactnative.dev/docs/environment-setup)) |
| 9 | +- For iOS: |
| 10 | + - macOS |
| 11 | + - Xcode (latest version recommended) |
| 12 | + - CocoaPods |
| 13 | + - Ruby (for CocoaPods) |
| 14 | +- For Android: |
| 15 | + - Android Studio |
| 16 | + - Java Development Kit (JDK) |
| 17 | + - Android SDK |
| 18 | + |
| 19 | +## Project Structure |
| 20 | + |
| 21 | +``` |
| 22 | +react-native-mparticle/ |
| 23 | +├── android/ # Native Android SDK implementation |
| 24 | +├── ios/ # Native iOS SDK implementation |
| 25 | +├── js/ # JavaScript/TypeScript SDK implementation |
| 26 | +├── sample/ # Sample app for testing |
| 27 | +└── ... |
| 28 | +``` |
| 29 | + |
| 30 | +## Initial Setup |
| 31 | + |
| 32 | +Install dependencies: |
| 33 | +```bash |
| 34 | +npm install |
| 35 | +``` |
| 36 | + |
| 37 | +## Running the Sample App |
| 38 | + |
| 39 | +The sample app is a great way to test your changes and see the SDK in action. |
| 40 | + |
| 41 | +### iOS Sample App |
| 42 | + |
| 43 | +1. Navigate to the sample directory: |
| 44 | +```bash |
| 45 | +cd sample |
| 46 | +``` |
| 47 | + |
| 48 | +2. Install JavaScript dependencies: |
| 49 | +```bash |
| 50 | +yarn install |
| 51 | +``` |
| 52 | + |
| 53 | +3. Install iOS dependencies: |
| 54 | +```bash |
| 55 | +cd ios |
| 56 | +pod install |
| 57 | +cd .. |
| 58 | +``` |
| 59 | + |
| 60 | +4. Start the Metro bundler: |
| 61 | +```bash |
| 62 | +yarn start |
| 63 | +``` |
| 64 | + |
| 65 | +5. Open the iOS workspace: |
| 66 | +```bash |
| 67 | +open ios/MParticleSample.xcworkspace |
| 68 | +``` |
| 69 | + |
| 70 | +6. In Xcode: |
| 71 | + - Select your target device/simulator |
| 72 | + - Update signing configuration if needed |
| 73 | + - Build and run (⌘R) |
| 74 | + |
| 75 | +### Android Sample App |
| 76 | + |
| 77 | +1. Navigate to the sample directory: |
| 78 | +```bash |
| 79 | +cd sample |
| 80 | +``` |
| 81 | + |
| 82 | +2. Install JavaScript dependencies: |
| 83 | +```bash |
| 84 | +npm install |
| 85 | +# or |
| 86 | +yarn install |
| 87 | +``` |
| 88 | + |
| 89 | +3. Start the Metro bundler: |
| 90 | +```bash |
| 91 | +npm start |
| 92 | +# or |
| 93 | +yarn start |
| 94 | +``` |
| 95 | + |
| 96 | +4. Open Android Studio: |
| 97 | + - Open the `android` folder in Android Studio |
| 98 | + - Let Gradle sync complete |
| 99 | + - Update any required SDK packages if prompted |
| 100 | + |
| 101 | +5. Run the app: |
| 102 | + - Select your target device/emulator |
| 103 | + - Click Run (or press ⇧F10) |
| 104 | + |
| 105 | +## Development Workflow |
| 106 | + |
| 107 | +### Building the SDK |
| 108 | + |
| 109 | +#### Android |
| 110 | +```bash |
| 111 | +cd android |
| 112 | +./gradlew build |
| 113 | +``` |
| 114 | + |
| 115 | +#### iOS |
| 116 | +```bash |
| 117 | +cd ios |
| 118 | +pod install |
| 119 | +``` |
| 120 | + |
| 121 | +### Running Tests |
| 122 | + |
| 123 | +```bash |
| 124 | +# Run JavaScript tests |
| 125 | +npm test |
| 126 | + |
| 127 | +# Run Android tests |
| 128 | +cd android |
| 129 | +./gradlew test |
| 130 | + |
| 131 | +# Run iOS tests |
| 132 | +cd ios/RNMParticle.xcodeproj |
| 133 | +xcodebuild test |
| 134 | +``` |
| 135 | + |
| 136 | +## Troubleshooting |
| 137 | + |
| 138 | +### Common iOS Issues |
| 139 | + |
| 140 | +1. "Missing config.h" error: |
| 141 | + This error occurs because the mParticle SDK contains Swift code which requires special handling. To fix this: |
| 142 | + |
| 143 | + a. Open your `sample/ios/Podfile` and add this block before the target definition: |
| 144 | + ```ruby |
| 145 | + pre_install do |installer| |
| 146 | + installer.pod_targets.each do |pod| |
| 147 | + if pod.name == 'mParticle-Apple-SDK' |
| 148 | + def pod.build_type; |
| 149 | + Pod::BuildType.new(:linkage => :dynamic, :packaging => :framework) |
| 150 | + end |
| 151 | + end |
| 152 | + end |
| 153 | + end |
| 154 | + ``` |
| 155 | + |
| 156 | + b. Clean and reinstall pods: |
| 157 | + ```bash |
| 158 | + cd sample/ios |
| 159 | + pod cache clean --all |
| 160 | + rm -rf Pods Podfile.lock |
| 161 | + pod install |
| 162 | + ``` |
| 163 | + |
| 164 | + c. If using Xcode 12 or later, ensure your project's Build Settings has "Allow Non-modular Includes In Framework Modules" set to Yes |
| 165 | + |
| 166 | +2. Pod install fails: |
| 167 | + - Try cleaning the pod cache: `pod cache clean --all` |
| 168 | + - Delete Podfile.lock and try again |
| 169 | + - Ensure CocoaPods is up to date: `bundle update` |
| 170 | + |
| 171 | +3. Build errors: |
| 172 | + - Clean build folder in Xcode (⇧⌘K) |
| 173 | + - Delete derived data: `rm -rf ~/Library/Developer/Xcode/DerivedData` |
| 174 | + - Ensure all dependencies are properly installed |
| 175 | + |
| 176 | +### Common Android Issues |
| 177 | + |
| 178 | +1. Gradle sync fails: |
| 179 | + - Check Android Studio SDK Manager for missing packages |
| 180 | + - Update Gradle version if needed |
| 181 | + - Clean project and rebuild |
| 182 | + |
| 183 | +2. Build errors: |
| 184 | + - Run `./gradlew clean` |
| 185 | + - Invalidate caches in Android Studio |
| 186 | + - Ensure all dependencies are properly installed |
| 187 | + |
| 188 | +## Contributing |
| 189 | + |
| 190 | +1. Create a feature branch |
| 191 | +2. Make your changes |
| 192 | +3. Test thoroughly |
| 193 | +4. Create a pull request |
| 194 | +5. Ensure CI passes |
| 195 | +6. Request review |
| 196 | + |
| 197 | +## Release Process |
| 198 | + |
| 199 | +1. Update version numbers: |
| 200 | + - package.json |
| 201 | + - android/build.gradle |
| 202 | + - ios/RNMParticle.podspec |
| 203 | + |
| 204 | +2. Update CHANGELOG.md |
| 205 | + |
| 206 | +3. Create release PR |
| 207 | + |
| 208 | +4. After merge, create a new release on GitHub |
| 209 | + |
| 210 | +5. Publish to npm: |
| 211 | +```bash |
| 212 | +npm publish |
| 213 | +``` |
0 commit comments