Skip to content

Commit 48b6878

Browse files
committed
WIP update sample apps
1 parent a09018c commit 48b6878

File tree

17 files changed

+6582
-4121
lines changed

17 files changed

+6582
-4121
lines changed

ONBOARDING.md

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
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+
```

android/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ buildscript {
44
google()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:7.4.2'
7+
classpath 'com.android.tools.build:gradle:8.1.4'
88
}
99
}
1010

1111
plugins {
1212
id "org.sonarqube" version "4.4.1.3373"
13-
id "org.jlleitschuh.gradle.ktlint" version "11.6.1"
13+
// id "org.jlleitschuh.gradle.ktlint" version "11.6.1"
1414
}
1515

1616
sonarqube {
@@ -21,10 +21,11 @@ sonarqube {
2121
}
2222
}
2323

24-
apply plugin: 'org.jlleitschuh.gradle.ktlint'
24+
// apply plugin: 'org.jlleitschuh.gradle.ktlint'
2525
apply plugin: 'com.android.library'
2626

2727
android {
28+
namespace 'com.mparticle.react'
2829
compileSdkVersion 33
2930

3031
defaultConfig {
@@ -55,7 +56,7 @@ repositories {
5556
}
5657

5758
dependencies {
58-
compileOnly 'com.facebook.react:react-native:0.20.1'
59+
api 'com.facebook.react:react-native'
5960

6061
//
6162
// In your app, you should include mParticle core like this:
@@ -64,7 +65,7 @@ dependencies {
6465
//
6566
// (See https://github.com/mparticle/mparticle-android-sdk for the latest version)
6667
//
67-
compileOnly 'com.mparticle:android-core:[5.9.3, )'
68+
api 'com.mparticle:android-core:[5.9.3, )'
6869

6970
//
7071
// And, if you want to include kits, you can do so as follows:

android/gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ expo.webp.enabled=true
5151
# Enable animated webp support (~3.4 MB increase)
5252
# Disabled by default because iOS doesn't support animated webp
5353
expo.webp.animated=false
54+
55+
sonar.gradle.skipCompile=true

ios/RNMParticle.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
172172
GCC_WARN_UNUSED_FUNCTION = YES;
173173
GCC_WARN_UNUSED_VARIABLE = YES;
174-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
174+
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
175175
MTL_ENABLE_DEBUG_INFO = YES;
176176
ONLY_ACTIVE_ARCH = YES;
177177
SDKROOT = iphoneos;
@@ -213,7 +213,7 @@
213213
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
214214
GCC_WARN_UNUSED_FUNCTION = YES;
215215
GCC_WARN_UNUSED_VARIABLE = YES;
216-
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
216+
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
217217
MTL_ENABLE_DEBUG_INFO = NO;
218218
SDKROOT = iphoneos;
219219
VALIDATE_PRODUCT = YES;

metro.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Metro configuration for React Native
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
*/
7+
8+
module.exports = {
9+
transformer: {
10+
getTransformOptions: async () => ({
11+
transform: {
12+
experimentalImportSupport: false,
13+
inlineRequires: true,
14+
},
15+
}),
16+
},
17+
};

0 commit comments

Comments
 (0)