Skip to content

Commit e4105e2

Browse files
authored
fix: React Native Codegen issue with version 0.84 (#284)
1 parent d9db901 commit e4105e2

14 files changed

Lines changed: 1549 additions & 1916 deletions

File tree

.github/workflows/pull-request.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ jobs:
110110
with:
111111
xcode-version: latest-stable
112112

113+
- name: Set Xcode Toolchain
114+
run: echo "TOOLCHAINS=com.apple.dt.toolchain.XcodeDefault" >> $GITHUB_ENV
115+
113116
- name: Setup iOS Simulator
114117
uses: futureware-tech/simulator-action@v5
115118
id: simulator

android/src/main/java/com/mparticle/react/MParticleModule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class MParticleModule(
179179
},
180180
)
181181
} else {
182-
callback.invoke()
182+
callback.invoke(null, WritableNativeMap())
183183
}
184184
}
185185

ios/RNMParticle/RNMParticle.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ + (void)load {
163163
{
164164
MParticleUser *selectedUser = [[MParticleUser alloc] init];
165165
selectedUser.userId = [NSNumber numberWithLong:mpid.longLongValue];
166-
callback(@[[NSNull null], [selectedUser userAttributes]]);
166+
NSDictionary *attributes = [selectedUser userAttributes] ?: @{};
167+
callback(@[[NSNull null], attributes]);
167168
}
168169

169170
RCT_EXPORT_METHOD(setUserTag:(NSString *)mpid tag:(NSString *)tag)

js/codegenSpecs/NativeMParticle.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import type { TurboModule } from 'react-native';
22
import { TurboModuleRegistry } from 'react-native';
3+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
34

45
export type CustomAttributes = { [key: string]: string | number | boolean };
5-
export type UserAttributes = {
6-
[key: string]: string | string[] | number | boolean | null;
7-
};
6+
export type UserAttributes = UnsafeObject;
87
export type UserIdentities = { [key: string]: string };
98

109
export interface Product {
@@ -153,7 +152,7 @@ export interface Spec extends TurboModule {
153152
mpid: string,
154153
callback: (
155154
error: CallbackError | null,
156-
result: UserAttributes | null
155+
result: UserAttributes
157156
) => void
158157
): void;
159158
setUserTag(mpid: string, tag: string): void;

sample/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def enableProguardInReleaseBuilds = false
7070
* give correct results when using with locales other than en-US. Note that
7171
* this variant is about 6MiB larger per architecture than default.
7272
*/
73-
def jscFlavor = 'org.webkit:android-jsc:+'
73+
def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
7474

7575
android {
7676
ndkVersion rootProject.ext.ndkVersion

sample/android/app/src/main/java/com/mparticlesample/MainApplication.kt

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,33 @@ import android.app.Application
44
import com.facebook.react.PackageList
55
import com.facebook.react.ReactApplication
66
import com.facebook.react.ReactHost
7-
import com.facebook.react.ReactNativeHost
8-
import com.facebook.react.ReactPackage
9-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
7+
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
108
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11-
import com.facebook.react.defaults.DefaultReactNativeHost
12-
import com.facebook.react.soloader.OpenSourceMergedSoMapping
13-
import com.facebook.soloader.SoLoader
9+
import com.mparticle.react.MParticlePackage
1410
import com.mparticle.MParticle
1511
import com.mparticle.MParticleOptions
1612
import com.mparticle.identity.IdentityApiRequest
17-
import com.mparticle.react.MParticlePackage
1813

1914
class MainApplication : Application(), ReactApplication {
2015

21-
override val reactNativeHost: ReactNativeHost =
22-
object : DefaultReactNativeHost(this) {
23-
override fun getPackages(): List<ReactPackage> =
24-
PackageList(this).packages.apply {
25-
add(MParticlePackage())
26-
}
27-
28-
override fun getJSMainModuleName(): String = "index"
29-
30-
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
31-
32-
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
33-
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
34-
}
35-
36-
override val reactHost: ReactHost
37-
get() = getDefaultReactHost(applicationContext, reactNativeHost)
16+
override val reactHost: ReactHost by lazy {
17+
getDefaultReactHost(
18+
context = applicationContext,
19+
packageList =
20+
PackageList(this).packages.apply {
21+
add(MParticlePackage())
22+
},
23+
)
24+
}
3825

3926
override fun onCreate() {
4027
super.onCreate()
41-
SoLoader.init(this, OpenSourceMergedSoMapping)
42-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
43-
// If you opted-in for the New Architecture, we load the native entry point for this app.
44-
load()
45-
}
28+
loadReactNative(this)
29+
4630
val identityRequest = IdentityApiRequest.withEmptyUser()
4731

4832
val options = MParticleOptions.builder(this)
49-
.credentials("REPLACE ME","REPLACE ME")
33+
.credentials("REPLACE_ME","REPLACE_ME")
5034
.logLevel(MParticle.LogLevel.VERBOSE)
5135
.identify(identityRequest.build())
5236
.build()

sample/android/build.gradle

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
buildscript {
22
ext {
3-
buildToolsVersion = "35.0.0"
3+
buildToolsVersion = "36.0.0"
44
minSdkVersion = 24
5-
compileSdkVersion = 35
6-
targetSdkVersion = 34
7-
ndkVersion = "26.1.10909125"
8-
kotlinVersion = "1.9.25"
5+
compileSdkVersion = 36
6+
targetSdkVersion = 36
7+
ndkVersion = "27.1.12297006"
8+
kotlinVersion = "2.1.20"
99
}
1010
repositories {
1111
google()
@@ -18,12 +18,4 @@ buildscript {
1818
}
1919
}
2020

21-
allprojects {
22-
repositories {
23-
mavenLocal()
24-
google()
25-
mavenCentral()
26-
}
27-
}
28-
2921
apply plugin: "com.facebook.react.rootproject"

sample/android/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ newArchEnabled=true
3737
# Use this property to enable or disable the Hermes JS engine.
3838
# If set to false, you will be using JSC instead.
3939
hermesEnabled=true
40+
41+
# Use this property to enable edge-to-edge display support.
42+
# This allows your app to draw behind system bars for an immersive UI.
43+
# Note: Only works with ReactActivity and should not be used with custom Activity.
44+
edgeToEdgeEnabled=false

sample/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

sample/ios/MParticleSample.xcodeproj/project.pbxproj

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,10 @@
277277
inputFileListPaths = (
278278
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-frameworks-${CONFIGURATION}-input-files.xcfilelist",
279279
);
280-
inputPaths = (
281-
);
282280
name = "[CP] Embed Pods Frameworks";
283281
outputFileListPaths = (
284282
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-frameworks-${CONFIGURATION}-output-files.xcfilelist",
285283
);
286-
outputPaths = (
287-
);
288284
runOnlyForDeploymentPostprocessing = 0;
289285
shellPath = /bin/sh;
290286
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-frameworks.sh\"\n";
@@ -342,14 +338,10 @@
342338
inputFileListPaths = (
343339
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
344340
);
345-
inputPaths = (
346-
);
347341
name = "[CP] Embed Pods Frameworks";
348342
outputFileListPaths = (
349343
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
350344
);
351-
outputPaths = (
352-
);
353345
runOnlyForDeploymentPostprocessing = 0;
354346
shellPath = /bin/sh;
355347
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-frameworks.sh\"\n";
@@ -363,14 +355,10 @@
363355
inputFileListPaths = (
364356
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-resources-${CONFIGURATION}-input-files.xcfilelist",
365357
);
366-
inputPaths = (
367-
);
368358
name = "[CP] Copy Pods Resources";
369359
outputFileListPaths = (
370360
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-resources-${CONFIGURATION}-output-files.xcfilelist",
371361
);
372-
outputPaths = (
373-
);
374362
runOnlyForDeploymentPostprocessing = 0;
375363
shellPath = /bin/sh;
376364
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample/Pods-MParticleSample-resources.sh\"\n";
@@ -384,14 +372,10 @@
384372
inputFileListPaths = (
385373
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-resources-${CONFIGURATION}-input-files.xcfilelist",
386374
);
387-
inputPaths = (
388-
);
389375
name = "[CP] Copy Pods Resources";
390376
outputFileListPaths = (
391377
"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-resources-${CONFIGURATION}-output-files.xcfilelist",
392378
);
393-
outputPaths = (
394-
);
395379
runOnlyForDeploymentPostprocessing = 0;
396380
shellPath = /bin/sh;
397381
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MParticleSample-MParticleSampleTests/Pods-MParticleSample-MParticleSampleTests-resources.sh\"\n";
@@ -596,18 +580,27 @@
596580
);
597581
MTL_ENABLE_DEBUG_INFO = YES;
598582
ONLY_ACTIVE_ARCH = YES;
583+
OTHER_CFLAGS = (
584+
"$(inherited)",
585+
"-DRCT_REMOVE_LEGACY_ARCH=1",
586+
);
599587
OTHER_CPLUSPLUSFLAGS = (
600588
"$(OTHER_CFLAGS)",
601589
"-DFOLLY_NO_CONFIG",
602590
"-DFOLLY_MOBILE=1",
603591
"-DFOLLY_USE_LIBCPP=1",
604592
"-DFOLLY_CFG_NO_COROUTINES=1",
605593
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
594+
"-DRCT_REMOVE_LEGACY_ARCH=1",
595+
);
596+
OTHER_LDFLAGS = (
597+
"$(inherited)",
598+
" ",
606599
);
607-
OTHER_LDFLAGS = "$(inherited) ";
608600
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
609601
SDKROOT = iphoneos;
610602
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
603+
SWIFT_ENABLE_EXPLICIT_MODULES = NO;
611604
USE_HERMES = true;
612605
};
613606
name = Debug;
@@ -665,17 +658,26 @@
665658
"\"$(inherited)\"",
666659
);
667660
MTL_ENABLE_DEBUG_INFO = NO;
661+
OTHER_CFLAGS = (
662+
"$(inherited)",
663+
"-DRCT_REMOVE_LEGACY_ARCH=1",
664+
);
668665
OTHER_CPLUSPLUSFLAGS = (
669666
"$(OTHER_CFLAGS)",
670667
"-DFOLLY_NO_CONFIG",
671668
"-DFOLLY_MOBILE=1",
672669
"-DFOLLY_USE_LIBCPP=1",
673670
"-DFOLLY_CFG_NO_COROUTINES=1",
674671
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
672+
"-DRCT_REMOVE_LEGACY_ARCH=1",
673+
);
674+
OTHER_LDFLAGS = (
675+
"$(inherited)",
676+
" ",
675677
);
676-
OTHER_LDFLAGS = "$(inherited) ";
677678
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
678679
SDKROOT = iphoneos;
680+
SWIFT_ENABLE_EXPLICIT_MODULES = NO;
679681
USE_HERMES = true;
680682
VALIDATE_PRODUCT = YES;
681683
};

0 commit comments

Comments
 (0)