From 5b6f18b0360cd5ba997cf03225c8355dd297ee63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Thu, 22 Oct 2026 00:57:03 -0700 Subject: [PATCH] Build the template app with RN_STRICT_API (#59224) Summary: Pull Request resolved: https://github.com/react/react-native/pull/59224 Turn on the C++ stable API checks (`RN_STRICT_API`) in the template apps CI builds, so the opt-ins, React Native's app-facing headers and the generated codegen and autolinking code are compiled in strict mode the way a new app would build them: - `private/helloworld`: `strictCxxApiEnabled=true` in `android/gradle.properties`, and the Podfile sets `RN_STRICT_API=1` unless the environment already sets it (`RN_STRICT_API=0 pod install` opts out). - Community template CI (cloned at build time): `build-android-templateapp.yml` appends `strictCxxApiEnabled=true` to the generated app's `gradle.properties`, and `e2e-ios-templateapp.yml` runs its `pod install` with `RN_STRICT_API=1`. Changelog: [Internal] ___ landed-with-radar-review Differential Revision: D126330998 fbshipit-source-id: 051b55482f4fd94aabe63c202e3415353d152b9b --- .github/workflows/build-android-templateapp.yml | 1 + .github/workflows/e2e-ios-templateapp.yml | 2 +- private/helloworld/android/gradle.properties | 1 + private/helloworld/ios/Podfile | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-android-templateapp.yml b/.github/workflows/build-android-templateapp.yml index 41d5af9d94a..b187466cba6 100644 --- a/.github/workflows/build-android-templateapp.yml +++ b/.github/workflows/build-android-templateapp.yml @@ -58,6 +58,7 @@ jobs: --pathToLocalReactNative "$REACT_NATIVE_PKG" echo -e "\nreact.internal.mavenLocalRepo=$MAVEN_LOCAL" >> /tmp/RNTestProject/android/gradle.properties + echo "strictCxxApiEnabled=true" >> /tmp/RNTestProject/android/gradle.properties CAPITALIZED_FLAVOR=$(echo "${{ matrix.flavor }}" | awk '{print toupper(substr($0, 1, 1)) substr($0, 2)}') cd /tmp/RNTestProject/android diff --git a/.github/workflows/e2e-ios-templateapp.yml b/.github/workflows/e2e-ios-templateapp.yml index 780d880a174..e91b5ba0f72 100644 --- a/.github/workflows/e2e-ios-templateapp.yml +++ b/.github/workflows/e2e-ios-templateapp.yml @@ -81,7 +81,7 @@ jobs: export RCT_USE_LOCAL_RN_DEP=/tmp/third-party/ReactNativeDependencies${{ matrix.flavor }}.xcframework.tar.gz # Disable prebuilds for now, as they are causing issues with E2E tests for 0.82-stable branch export RCT_TESTONLY_RNCORE_TARBALL_PATH="/tmp/ReactCore/ReactCore${{ matrix.flavor }}.xcframework.tar.gz" - RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install + RN_STRICT_API=1 RCT_NEW_ARCH_ENABLED=$NEW_ARCH_ENABLED bundle exec pod install xcodebuild \ -scheme "RNTestProject" \ diff --git a/private/helloworld/android/gradle.properties b/private/helloworld/android/gradle.properties index 57765bfad91..6869615c126 100644 --- a/private/helloworld/android/gradle.properties +++ b/private/helloworld/android/gradle.properties @@ -11,6 +11,7 @@ reactNativeArchitectures=arm64-v8a newArchEnabled=true hermesEnabled=true edgeToEdgeEnabled=false +strictCxxApiEnabled=true # Opt out of built-in kotlin and new DSL behavior that ships with AGP 9. # Starting from AGP 10.x these opt outs will be removed. diff --git a/private/helloworld/ios/Podfile b/private/helloworld/ios/Podfile index 19bbc9faca0..18613ea6d2e 100644 --- a/private/helloworld/ios/Podfile +++ b/private/helloworld/ios/Podfile @@ -3,6 +3,9 @@ require "../../../packages/react-native/scripts/cocoapods/autolinking.rb" platform :ios, min_ios_version_supported prepare_react_native_project! +# Build with the C++ stable API enforced. Run `RN_STRICT_API=0 pod install` to opt out. +ENV['RN_STRICT_API'] ||= '1' + linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green