From c43b0be8ff226575ad0f6e9e7c63f6aa7c8e9cdc Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Wed, 21 Oct 2026 18:44:40 +0200 Subject: [PATCH] feat: remove experimental label from c++ template the c++ template no longer requires includesGeneratedCode: true --- .github/workflows/build-templates.yml | 5 ----- docs/pages/create.md | 2 -- .../src/exampleApp/dependencies.ts | 12 ------------ .../create-react-native-library/src/prompt.ts | 4 ++-- .../templates/common/$.github/workflows/ci.yml | 10 ---------- .../templates/common/$package.json | 16 +--------------- .../templates/common/CONTRIBUTING.md | 15 --------------- .../templates/cpp-library/react-native.config.js | 1 - .../cpp-library/{%- project.name %}.podspec | 2 +- 9 files changed, 4 insertions(+), 63 deletions(-) diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml index 8949d201e..3559e61a7 100644 --- a/.github/workflows/build-templates.yml +++ b/.github/workflows/build-templates.yml @@ -173,11 +173,6 @@ jobs: working-directory: ${{ env.work_dir }} run: yarn nitrogen - - name: Generate codegen native code - if: matrix.type.language == 'cpp' - working-directory: ${{ env.work_dir }} - run: yarn bob build --target codegen - - name: Cache turborepo if: env.android_build == 1 || env.ios_build == 1 uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 diff --git a/docs/pages/create.md b/docs/pages/create.md index c5dae2469..b00dcf210 100644 --- a/docs/pages/create.md +++ b/docs/pages/create.md @@ -95,5 +95,3 @@ Once the project is created, you can follow the official React Native docs to le - [Fabric Components](https://reactnative.dev/docs/fabric-native-components-introduction) Turbo Modules and Fabric components don't have native support for Swift. If you want to write the iOS implementation in Swift for a Turbo Module or Fabric View, see [Swift with Turbo Modules and Fabric](./swift-new-architecture.md). - -> Note: The C++ template is currently experimental and only works with `includesGeneratedCode: true`. This can make it incompatible with React Native versions other than the one used to generate the codegen files. See [Including Generated Code into Libraries](https://reactnative.dev/docs/the-new-architecture/codegen-cli#including-generated-code-into-libraries) in the React Native docs for more details. diff --git a/packages/create-react-native-library/src/exampleApp/dependencies.ts b/packages/create-react-native-library/src/exampleApp/dependencies.ts index 0b720afa9..fc12a6b77 100644 --- a/packages/create-react-native-library/src/exampleApp/dependencies.ts +++ b/packages/create-react-native-library/src/exampleApp/dependencies.ts @@ -4,9 +4,6 @@ import sortObjectKeys from '../utils/sortObjectKeys.ts'; type PackageJson = { devDependencies?: Record; - 'react-native-builder-bob'?: { - targets?: (string | [string, unknown])[]; - }; }; export async function alignDependencyVersionsWithExampleApp( @@ -24,15 +21,6 @@ export async function alignDependencyVersionsWithExampleApp( '@react-native/babel-preset', ]; - const usesCodegen = - pkg['react-native-builder-bob']?.targets?.some((target) => - Array.isArray(target) ? target[0] === 'codegen' : target === 'codegen' - ) ?? false; - - if (usesCodegen) { - PACKAGES_TO_COPY.push('@react-native-community/cli'); - } - const devDependencies: Record = {}; PACKAGES_TO_COPY.forEach((name) => { diff --git a/packages/create-react-native-library/src/prompt.ts b/packages/create-react-native-library/src/prompt.ts index bb64b639f..7fc206f69 100644 --- a/packages/create-react-native-library/src/prompt.ts +++ b/packages/create-react-native-library/src/prompt.ts @@ -64,7 +64,7 @@ const LANGUAGE_CHOICES: { types: ['turbo-module', 'fabric-view'], }, { - title: 'C++ (Experimental)', + title: 'C++', value: 'cpp', types: ['turbo-module'], }, @@ -364,7 +364,7 @@ export const prompt = create(['[name]'], { const answers = prompt.read(); if (answers.languages === 'cpp') { - return choice.value !== 'vanilla'; + return choice.value === 'test-app'; } return false; diff --git a/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml b/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml index 5f9b12860..b6cf8b81c 100644 --- a/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml +++ b/packages/create-react-native-library/templates/common/$.github/workflows/ci.yml @@ -79,11 +79,6 @@ jobs: - name: Generate nitrogen code run: yarn nitrogen <% } -%> -<% if (project.cpp) { -%> - - - name: Generate codegen native code - run: yarn bob build --target codegen -<% } -%> - name: Cache turborepo for Android uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 @@ -157,11 +152,6 @@ jobs: - name: Generate nitrogen code run: yarn nitrogen <% } -%> -<% if (project.cpp) { -%> - - - name: Generate codegen native code - run: yarn bob build --target codegen -<% } -%> - name: Cache turborepo for iOS uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 diff --git a/packages/create-react-native-library/templates/common/$package.json b/packages/create-react-native-library/templates/common/$package.json index 526681ed0..a922c9030 100644 --- a/packages/create-react-native-library/templates/common/$package.json +++ b/packages/create-react-native-library/templates/common/$package.json @@ -69,9 +69,6 @@ "registry": "https://registry.npmjs.org/" }, "devDependencies": { -<% if (project.cpp) { -%> - "@react-native-community/cli": "20.2.0", -<% } -%> "@react-native/babel-preset": "0.88.0", "@types/react": "^19.2.0", "del-cli": "^8.0.1", @@ -125,9 +122,7 @@ { "project": "tsconfig.build.json" } - ]<% if (project.cpp) { -%>, - "codegen" -<% } -%> + ] ] <% if (project.moduleConfig === 'turbo-modules' || project.viewConfig === 'fabric-view') { -%> }, @@ -135,12 +130,6 @@ "name": "<%- project.name -%><%- project.viewConfig !== null ? 'View': '' -%>Spec", "type": "<%- project.viewConfig !== null ? 'all': 'modules' -%>", "jsSrcsDir": "src", -<% if (project.cpp) { -%> - "outputDir": { - "ios": "ios/generated", - "android": "android/generated" - }, -<% } -%> "android": { "javaPackageName": "com.<%- project.package %>" <% if (project.viewConfig === 'fabric-view') { -%> @@ -153,9 +142,6 @@ } <% } -%> } -<% if (project.cpp) { -%>, - "includesGeneratedCode": true -<% } -%> <% } -%> } } diff --git a/packages/create-react-native-library/templates/common/CONTRIBUTING.md b/packages/create-react-native-library/templates/common/CONTRIBUTING.md index e1dd10fff..78cdab2b4 100644 --- a/packages/create-react-native-library/templates/common/CONTRIBUTING.md +++ b/packages/create-react-native-library/templates/common/CONTRIBUTING.md @@ -37,21 +37,6 @@ To invoke **Nitrogen**, use the following command: yarn nitrogen ``` -<% } -%> -<% if (project.cpp) { -%> -You need to run React Native Codegen to generate the native scaffolding for the C++ Turbo Module. The example app will not build without these generated files. - -Run **Codegen** in following cases: - -- When you make changes to `src/Native<%- project.name -%>.ts`. -- When running the project for the first time (since the generated files are not committed to the repository). - -To invoke **Codegen**, use the following command: - -```sh -yarn bob build --target codegen -``` - <% } -%> The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make. diff --git a/packages/create-react-native-library/templates/cpp-library/react-native.config.js b/packages/create-react-native-library/templates/cpp-library/react-native.config.js index d0e6274ff..346ced327 100644 --- a/packages/create-react-native-library/templates/cpp-library/react-native.config.js +++ b/packages/create-react-native-library/templates/cpp-library/react-native.config.js @@ -5,7 +5,6 @@ module.exports = { dependency: { platforms: { android: { - cmakeListsPath: 'generated/jni/CMakeLists.txt', cxxModuleCMakeListsModuleName: '<%- project.identifier -%>', cxxModuleCMakeListsPath: 'CMakeLists.txt', cxxModuleHeaderName: '<%- project.name -%>Impl', diff --git a/packages/create-react-native-library/templates/cpp-library/{%- project.name %}.podspec b/packages/create-react-native-library/templates/cpp-library/{%- project.name %}.podspec index 8ee7ecb54..e0e23482d 100644 --- a/packages/create-react-native-library/templates/cpp-library/{%- project.name %}.podspec +++ b/packages/create-react-native-library/templates/cpp-library/{%- project.name %}.podspec @@ -13,7 +13,7 @@ Pod::Spec.new do |s| s.platforms = { :ios => min_ios_version_supported } s.source = { :git => "<%- repo -%>.git", :tag => "#{s.version}" } - s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}", "ios/generated/*.{h,cpp,mm}" + s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}" s.private_header_files = "ios/**/*.h" install_modules_dependencies(s)