Skip to content

Commit 1706d80

Browse files
authored
refactor: drop old arch and cpp templates (#818)
## Summarry The large number of templates makes it difficult to maintain and test. so this reduces the number of templates: - Drop old architecture templates - users can use codegen or older version of crnl - Drop cpp templates - our cpp template isn't a pure cpp template, we should eventually have it ## Test plan Tested building each template: turbo module, fabric view, nitro module and ran the example app for Android & iOS to verify it works. - Nitro fails locally on iOS due to this mrousavy/nitro#422, so had to force the iOS version to make it work - Turbo module works fine locally on iOS but fails on CI Both of them seem related to XCode 16 and not this change.
1 parent 688e53f commit 1706d80

File tree

29 files changed

+86
-517
lines changed

29 files changed

+86
-517
lines changed

.github/workflows/build-templates.yml

+17-33
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,19 @@ jobs:
3030
- ubuntu
3131
- macos
3232
type:
33-
- turbo-module
34-
- fabric-view
35-
- legacy-module
36-
- legacy-view
37-
- nitro-module
38-
language:
39-
- kotlin-objc
40-
- kotlin-swift
41-
- cpp
42-
exclude:
43-
- type: turbo-module
44-
language: kotlin-swift
45-
- type: fabric-view
46-
language: kotlin-swift
47-
- type: fabric-view
48-
language: cpp
49-
- type: legacy-view
50-
language: cpp
51-
- type: nitro-module
33+
- name: turbo-module
5234
language: kotlin-objc
53-
- type: nitro-module
54-
language: cpp
35+
- name: fabric-view
36+
language: kotlin-objc
37+
- name: nitro-module
38+
language: kotlin-swift
5539
include:
5640
- os: ubuntu
57-
type: library
58-
language: js
41+
type.name: library
42+
type.language: js
5943

6044
concurrency:
61-
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}
45+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}
6246
cancel-in-progress: true
6347

6448
runs-on: ${{ matrix.os }}-latest
@@ -76,7 +60,7 @@ jobs:
7660
7761
- name: Get working directory
7862
run: |
79-
echo "work_dir=${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}" >> $GITHUB_ENV
63+
echo "work_dir=${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}" >> $GITHUB_ENV
8064
8165
- name: Create library
8266
run: |
@@ -88,9 +72,9 @@ jobs:
8872
--author-email test@test \
8973
--author-url https://test.test \
9074
--repo-url https://test.test \
91-
--type ${{ matrix.type }} \
92-
--languages ${{ matrix.language }} \
93-
--example ${{ matrix.language == 'js' && 'expo' || 'vanilla' }} \
75+
--type ${{ matrix.type.name }} \
76+
--languages ${{ matrix.type.language }} \
77+
--example ${{ matrix.type.language == 'js' && 'expo' || 'vanilla' }} \
9478
--no-local
9579
9680
- name: Restore dependencies of library
@@ -135,14 +119,14 @@ jobs:
135119
run: |
136120
# Build Android for only some matrices to skip redundant builds
137121
if [[ ${{ matrix.os }} == ubuntu ]]; then
138-
if [[ ${{ matrix.type }} == *-view && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == cpp ]]; then
122+
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == *-objc ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == *-objc ]]; then
139123
echo "android_build=1" >> $GITHUB_ENV
140124
fi
141125
fi
142126
143127
# Build iOS for only some matrices to skip redundant builds
144128
if [[ ${{ matrix.os }} == macos ]]; then
145-
if [[ ${{ matrix.type }} == *-view && ${{ matrix.language }} == kotlin-* ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == kotlin-* ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == cpp ]]; then
129+
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == kotlin-* ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == kotlin-* ]]; then
146130
echo "ios_build=1" >> $GITHUB_ENV
147131
fi
148132
fi
@@ -153,9 +137,9 @@ jobs:
153137
with:
154138
path: |
155139
${{ env.work_dir }}/.turbo
156-
key: ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
140+
key: ${{ runner.os }}-library-turborepo-${{ matrix.type.name }}-${{ matrix.type.language }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
157141
restore-keys: |
158-
${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-
142+
${{ runner.os }}-library-turborepo-${{ matrix.type.name }}-${{ matrix.type.language }}-
159143
160144
- name: Check turborepo cache
161145
if: env.android_build == 1 || env.ios_build == 1
@@ -194,7 +178,7 @@ jobs:
194178
195179
- name: Build example (Web)
196180
working-directory: ${{ env.work_dir }}
197-
if: matrix.language == 'js'
181+
if: matrix.type.language == 'js'
198182
run: |
199183
yarn example expo export --platform web
200184

docs/pages/create.md

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ This will ask you a few questions about your project and generate a new project
2929

3030
After the project is created, you can find the development workflow in the generated `CONTRIBUTING.md` file.
3131

32+
> Note: If you want to create a library using the legacy native modules and view APIs instead of the new architecture, you can use the `0.49.8` version of `create-react-native-library`: `npx [email protected] awesome-library`.
33+
3234
## Local library
3335

3436
While the default templates are for libraries that are published to npm, you can also create a local library that is not published but used locally in your app.

packages/create-react-native-library/src/exampleApp/generateExampleApp.ts

+25-31
Original file line numberDiff line numberDiff line change
@@ -261,39 +261,33 @@ export default async function generateExampleApp({
261261
'android.enableJetifier=false'
262262
);
263263

264-
// If the library is on new architecture, enable new arch for iOS and Android
265-
if (config.project.arch === 'new') {
266-
// iOS
267-
// Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile
268-
const podfile = await fs.readFile(
269-
path.join(directory, 'ios', 'Podfile'),
270-
'utf8'
271-
);
264+
// Enable new arch for iOS and Android
265+
// iOS
266+
// Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile
267+
const podfile = await fs.readFile(
268+
path.join(directory, 'ios', 'Podfile'),
269+
'utf8'
270+
);
272271

273-
await fs.writeFile(
274-
path.join(directory, 'ios', 'Podfile'),
275-
"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile
276-
);
272+
await fs.writeFile(
273+
path.join(directory, 'ios', 'Podfile'),
274+
"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile
275+
);
277276

278-
// Android
279-
// Make sure newArchEnabled=true is present in android/gradle.properties
280-
if (gradleProperties.split('\n').includes('#newArchEnabled=true')) {
281-
gradleProperties = gradleProperties.replace(
282-
'#newArchEnabled=true',
283-
'newArchEnabled=true'
284-
);
285-
} else if (
286-
gradleProperties.split('\n').includes('newArchEnabled=false')
287-
) {
288-
gradleProperties = gradleProperties.replace(
289-
'newArchEnabled=false',
290-
'newArchEnabled=true'
291-
);
292-
} else if (
293-
!gradleProperties.split('\n').includes('newArchEnabled=true')
294-
) {
295-
gradleProperties += '\nnewArchEnabled=true';
296-
}
277+
// Android
278+
// Make sure newArchEnabled=true is present in android/gradle.properties
279+
if (gradleProperties.split('\n').includes('#newArchEnabled=true')) {
280+
gradleProperties = gradleProperties.replace(
281+
'#newArchEnabled=true',
282+
'newArchEnabled=true'
283+
);
284+
} else if (gradleProperties.split('\n').includes('newArchEnabled=false')) {
285+
gradleProperties = gradleProperties.replace(
286+
'newArchEnabled=false',
287+
'newArchEnabled=true'
288+
);
289+
} else if (!gradleProperties.split('\n').includes('newArchEnabled=true')) {
290+
gradleProperties += '\nnewArchEnabled=true';
297291
}
298292

299293
await fs.writeFile(

packages/create-react-native-library/src/input.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ export type ArgName =
1818
| 'example'
1919
| 'reactNativeVersion';
2020

21-
export type ProjectLanguages = 'kotlin-objc' | 'kotlin-swift' | 'cpp' | 'js';
21+
export type ProjectLanguages = 'kotlin-objc' | 'kotlin-swift' | 'js';
2222

2323
export type ProjectType =
2424
| 'turbo-module'
2525
| 'fabric-view'
26-
| 'legacy-module'
27-
| 'legacy-view'
2826
| 'nitro-module'
2927
| 'library';
3028

@@ -36,17 +34,12 @@ const LANGUAGE_CHOICES: {
3634
{
3735
title: 'Kotlin & Swift',
3836
value: 'kotlin-swift',
39-
types: ['nitro-module', 'legacy-module', 'legacy-view'],
37+
types: ['nitro-module'],
4038
},
4139
{
4240
title: 'Kotlin & Objective-C',
4341
value: 'kotlin-objc',
44-
types: ['turbo-module', 'fabric-view', 'legacy-module', 'legacy-view'],
45-
},
46-
{
47-
title: 'C++ for Android & iOS',
48-
value: 'cpp',
49-
types: ['turbo-module', 'legacy-module'],
42+
types: ['turbo-module', 'fabric-view'],
5043
},
5144
{
5245
title: 'JavaScript for Android, iOS & Web',
@@ -101,16 +94,6 @@ const TYPE_CHOICES: {
10194
description:
10295
'type-safe, fast integration for native APIs to JS (experimental)',
10396
},
104-
{
105-
title: 'Legacy Native module',
106-
value: 'legacy-module',
107-
description: 'bridge for native APIs to JS (old architecture)',
108-
},
109-
{
110-
title: 'Legacy Native view',
111-
value: 'legacy-view',
112-
description: 'bridge for native views to JS (old architecture)',
113-
},
11497
{
11598
title: 'JavaScript library',
11699
value: 'library',
@@ -167,7 +150,6 @@ export const acceptedArgs: Record<ArgName, yargs.Options> = {
167150
} as const;
168151

169152
export type Args = Record<ArgName | 'name', string>;
170-
export type SupportedArchitecture = 'new' | 'legacy';
171153
export type ExampleApp = 'none' | 'test-app' | 'expo' | 'vanilla';
172154

173155
export type Answers = {

0 commit comments

Comments
 (0)