Skip to content

Commit 8850949

Browse files
abueideclaude
andauthored
feat(examples): add devbox integration for e2e-latest (#1266)
* feat(examples): add devbox integration for e2e-latest Add mobile-devtools plugin with Nix-managed Android/iOS SDKs for e2e-latest. Includes device definitions for API 36 and env-var-driven SDK version resolution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(e2e-latest): write .xcode.env.local in build:ios for devbox node path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(e2e-latest): enable New Architecture (RN 0.84 bridgeless) Enable newArchEnabled + hermesEnabled, upgrade Gradle to 9.3.1, rewrite settings.gradle for RN 0.84 autolinking, switch to Kotlin MainApplication, update to @react-navigation/native-stack v7, replace metro-react-native-babel-preset with @react-native/babel-preset, and simplify iOS Podfile for new arch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(e2e-latest): resolve build and deploy issues for iOS and Android Switch App.tsx from @react-navigation/stack to native-stack (removes gesture-handler dependency), fix app.json name mismatch causing runtime crash, add -arch arm64 for iOS simulator builds, and disable folly coroutines for Xcode 26 compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(examples): prevent Metro dev server from launching during release builds Add RCT_NO_LAUNCH_PACKAGER=1 to xcodebuild commands in both e2e-compat and e2e-latest. The Xcode "Start Packager" build phase was opening a persistent Metro terminal window despite SKIP_BUNDLING=1 being set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7b1f6a9 commit 8850949

29 files changed

Lines changed: 1332 additions & 1163 deletions

File tree

examples/e2e-compat/devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"build:android": ["cd android && ./gradlew assembleRelease && cd .."],
2424
"build:ios": [
2525
"echo \"export NODE_BINARY=$(which node)\" > ios/.xcode.env.local",
26-
"SKIP_BUNDLING=1 xcodebuild -workspace ios/AnalyticsReactNativeE2E.xcworkspace -scheme AnalyticsReactNativeE2E -configuration Release -sdk iphonesimulator -derivedDataPath ios/build build",
26+
"RCT_NO_LAUNCH_PACKAGER=1 SKIP_BUNDLING=1 xcodebuild -workspace ios/AnalyticsReactNativeE2E.xcworkspace -scheme AnalyticsReactNativeE2E -configuration Release -sdk iphonesimulator -derivedDataPath ios/build build",
2727
"node node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --bundle-output ios/build/Build/Products/Release-iphonesimulator/AnalyticsReactNativeE2E.app/main.jsbundle --assets-dest ios/build/Build/Products/Release-iphonesimulator/AnalyticsReactNativeE2E.app"
2828
],
2929
"test:android": [

examples/e2e-latest/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ yarn-error.log
6464

6565
# testing
6666
/coverage
67+
68+
# segkit reports
69+
/reports/

examples/e2e-latest/.yarnrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvedGitRepositories:
2+
- '**'
3+
4+
enableScripts: true

examples/e2e-latest/App.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import 'react-native-gesture-handler';
21
import * as React from 'react';
32
import {useState, useEffect} from 'react';
43
import {
54
NavigationContainer,
65
NavigationState,
76
PartialState,
87
} from '@react-navigation/native';
9-
import {createStackNavigator} from '@react-navigation/stack';
8+
import {createNativeStackNavigator} from '@react-navigation/native-stack';
109
import {AnalyticsProvider} from '@segment/analytics-react-native';
1110
import {
1211
Home,
@@ -16,8 +15,8 @@ import {
1615
onClientChange,
1716
} from '../e2e-shared/src/app';
1817

19-
const MainStack = createStackNavigator();
20-
const RootStack = createStackNavigator();
18+
const MainStack = createNativeStackNavigator();
19+
const RootStack = createNativeStackNavigator();
2120

2221
function MainStackScreen() {
2322
return (

examples/e2e-latest/android/app/build.gradle

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
23
apply plugin: "com.facebook.react"
34

5+
react {
6+
autolinkLibrariesWithApp()
7+
}
8+
49
/**
510
* This is the configuration block to customize your React Native Android app.
611
* By default you don't need to apply any configuration, just uncomment the lines you need.
@@ -73,6 +78,25 @@ android {
7378

7479
compileSdkVersion rootProject.ext.compileSdkVersion
7580

81+
externalNativeBuild {
82+
cmake {
83+
version System.getenv("CMAKE_VERSION") ?: "3.22.1"
84+
}
85+
}
86+
87+
defaultConfig {
88+
externalNativeBuild {
89+
cmake {
90+
cppFlags "-Wno-error=deprecated-declarations -fno-lto"
91+
arguments "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF"
92+
}
93+
}
94+
}
95+
96+
lint {
97+
checkReleaseBuilds false
98+
}
99+
76100
namespace "com.AnalyticsReactNativeE2E"
77101
defaultConfig {
78102
applicationId "com.AnalyticsReactNativeE2E"
@@ -118,5 +142,3 @@ dependencies {
118142
implementation jscFlavor
119143
}
120144
}
121-
122-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

examples/e2e-latest/android/app/src/main/java/com/analyticsreactnativeexample/MainActivity.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,13 @@
77

88
public class MainActivity extends ReactActivity {
99

10-
/**
11-
* Returns the name of the main component registered from JavaScript. This is used to schedule
12-
* rendering of the component.
13-
*/
1410
@Override
1511
protected String getMainComponentName() {
1612
return "AnalyticsReactNativeE2E";
1713
}
1814

19-
/**
20-
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
21-
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
22-
* (aka React 18) with two boolean flags.
23-
*/
2415
@Override
2516
protected ReactActivityDelegate createReactActivityDelegate() {
26-
return new DefaultReactActivityDelegate(
27-
this,
28-
getMainComponentName(),
29-
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
30-
DefaultNewArchitectureEntryPoint.getFabricEnabled());
17+
return new DefaultReactActivityDelegate(this, getMainComponentName(), true);
3118
}
3219
}

examples/e2e-latest/android/app/src/main/java/com/analyticsreactnativeexample/MainApplication.java

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.AnalyticsReactNativeE2E
2+
3+
import android.app.Application
4+
import com.facebook.react.PackageList
5+
import com.facebook.react.ReactApplication
6+
import com.facebook.react.ReactHost
7+
import com.facebook.react.ReactNativeApplicationEntryPoint
8+
import com.facebook.react.ReactNativeHost
9+
import com.facebook.react.ReactPackage
10+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
11+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
12+
import com.facebook.react.defaults.DefaultReactNativeHost
13+
14+
class MainApplication : Application(), ReactApplication {
15+
16+
override val reactNativeHost: ReactNativeHost =
17+
object : DefaultReactNativeHost(this) {
18+
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
19+
20+
override fun getPackages(): List<ReactPackage> = PackageList(this).packages
21+
22+
override fun getJSMainModuleName(): String = "index"
23+
24+
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
25+
}
26+
27+
override val reactHost: ReactHost
28+
get() = getDefaultReactHost(applicationContext, reactNativeHost)
29+
30+
override fun onCreate() {
31+
super.onCreate()
32+
ReactNativeApplicationEntryPoint.loadReactNative(this)
33+
}
34+
}

examples/e2e-latest/android/build.gradle

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
buildscript {
44
ext {
5-
// Default to the build-tools pinned in devbox; allow override via ANDROID_BUILD_TOOLS_VERSION.
6-
// Keep in sync with nix/flake.nix when ANDROID_BUILD_TOOLS_VERSION is unset.
7-
buildToolsVersion = System.getenv("ANDROID_BUILD_TOOLS_VERSION") ?: "30.0.3"
8-
minSdkVersion = 21
9-
compileSdkVersion = 33
10-
targetSdkVersion = 33
11-
kotlinVersion="1.7.20"
12-
13-
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
14-
ndkVersion = "23.1.7779620"
5+
def compileSdkEnv = System.getenv("ANDROID_COMPILE_SDK") ?: System.getenv("ANDROID_MAX_API") ?: "36"
6+
def targetSdkEnv = System.getenv("ANDROID_TARGET_SDK") ?: System.getenv("ANDROID_MAX_API") ?: "36"
7+
buildToolsVersion = System.getenv("ANDROID_BUILD_TOOLS_VERSION") ?: "36.1.0"
8+
def minSdkEnv = System.getenv("ANDROID_MIN_SDK") ?: "24"
9+
minSdkVersion = minSdkEnv.toInteger()
10+
compileSdkVersion = compileSdkEnv.toInteger()
11+
targetSdkVersion = targetSdkEnv.toInteger()
12+
kotlinVersion = "2.1.20"
13+
def ndkVersionEnv = System.getenv("ANDROID_NDK_VERSION")
14+
if (ndkVersionEnv) {
15+
ndkVersion = ndkVersionEnv
16+
}
1517
}
1618
repositories {
1719
google()
@@ -33,7 +35,18 @@ allprojects {
3335
}
3436

3537
google()
36-
jcenter()
3738
maven { url 'https://www.jitpack.io' }
3839
}
3940
}
41+
42+
subprojects {
43+
afterEvaluate { project ->
44+
if (project.hasProperty("android")) {
45+
project.android.buildToolsVersion = rootProject.ext.buildToolsVersion
46+
def cmakeVer = System.getenv("CMAKE_VERSION")
47+
if (cmakeVer && project.android.externalNativeBuild.cmake.path) {
48+
project.android.externalNativeBuild.cmake.version = cmakeVer
49+
}
50+
}
51+
}
52+
}

examples/e2e-latest/android/gradle.properties

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ android.enableJetifier=true
2727
# Use this property to specify which architecture you want to build.
2828
# You can also override it from the CLI using
2929
# ./gradlew <task> -PreactNativeArchitectures=x86_64
30-
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
30+
reactNativeArchitectures=arm64-v8a
3131

3232
# Use this property to enable support to the new architecture.
3333
# This will allow you to use TurboModules and the Fabric render in
3434
# your application. You should enable this flag either if you want
3535
# to write custom TurboModules/Fabric components OR use libraries that
3636
# are providing them.
37-
newArchEnabled=false
37+
newArchEnabled=true
3838

3939
# Use this property to enable or disable the Hermes JS engine.
4040
# If set to false, you will be using JSC instead.
4141
hermesEnabled=true
42+
43+
# Disable automatic SDK component downloads (Nix provides all SDK components)
44+
android.builder.sdkDownload=false

0 commit comments

Comments
 (0)