Skip to content

refactor: drop old arch and cpp templates #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 17 additions & 33 deletions .github/workflows/build-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,19 @@ jobs:
- ubuntu
- macos
type:
- turbo-module
- fabric-view
- legacy-module
- legacy-view
- nitro-module
language:
- kotlin-objc
- kotlin-swift
- cpp
exclude:
- type: turbo-module
language: kotlin-swift
- type: fabric-view
language: kotlin-swift
- type: fabric-view
language: cpp
- type: legacy-view
language: cpp
- type: nitro-module
- name: turbo-module
language: kotlin-objc
- type: nitro-module
language: cpp
- name: fabric-view
language: kotlin-objc
- name: nitro-module
language: kotlin-swift
include:
- os: ubuntu
type: library
language: js
type.name: library
type.language: js

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}
cancel-in-progress: true

runs-on: ${{ matrix.os }}-latest
Expand All @@ -76,7 +60,7 @@ jobs:

- name: Get working directory
run: |
echo "work_dir=${{ matrix.os }}-${{ matrix.type }}-${{ matrix.language }}" >> $GITHUB_ENV
echo "work_dir=${{ matrix.os }}-${{ matrix.type.name }}-${{ matrix.type.language }}" >> $GITHUB_ENV

- name: Create library
run: |
Expand All @@ -88,9 +72,9 @@ jobs:
--author-email test@test \
--author-url https://test.test \
--repo-url https://test.test \
--type ${{ matrix.type }} \
--languages ${{ matrix.language }} \
--example ${{ matrix.language == 'js' && 'expo' || 'vanilla' }} \
--type ${{ matrix.type.name }} \
--languages ${{ matrix.type.language }} \
--example ${{ matrix.type.language == 'js' && 'expo' || 'vanilla' }} \
--no-local

- name: Restore dependencies of library
Expand Down Expand Up @@ -135,14 +119,14 @@ jobs:
run: |
# Build Android for only some matrices to skip redundant builds
if [[ ${{ matrix.os }} == ubuntu ]]; then
if [[ ${{ matrix.type }} == *-view && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == *-objc ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == cpp ]]; then
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == *-objc ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == *-objc ]]; then
echo "android_build=1" >> $GITHUB_ENV
fi
fi

# Build iOS for only some matrices to skip redundant builds
if [[ ${{ matrix.os }} == macos ]]; then
if [[ ${{ matrix.type }} == *-view && ${{ matrix.language }} == kotlin-* ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == kotlin-* ]] || [[ ${{ matrix.type }} == *-module && ${{ matrix.language }} == cpp ]]; then
if [[ ${{ matrix.type.name }} == *-view && ${{ matrix.type.language }} == kotlin-* ]] || [[ ${{ matrix.type.name }} == *-module && ${{ matrix.type.language }} == kotlin-* ]]; then
echo "ios_build=1" >> $GITHUB_ENV
fi
fi
Expand All @@ -153,9 +137,9 @@ jobs:
with:
path: |
${{ env.work_dir }}/.turbo
key: ${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
key: ${{ runner.os }}-library-turborepo-${{ matrix.type.name }}-${{ matrix.type.language }}-${{ hashFiles(format('{0}/yarn.lock', env.work_dir)) }}
restore-keys: |
${{ runner.os }}-library-turborepo-${{ matrix.type }}-${{ matrix.language }}-
${{ runner.os }}-library-turborepo-${{ matrix.type.name }}-${{ matrix.type.language }}-

- name: Check turborepo cache
if: env.android_build == 1 || env.ios_build == 1
Expand Down Expand Up @@ -194,7 +178,7 @@ jobs:

- name: Build example (Web)
working-directory: ${{ env.work_dir }}
if: matrix.language == 'js'
if: matrix.type.language == 'js'
run: |
yarn example expo export --platform web

Expand Down
2 changes: 2 additions & 0 deletions docs/pages/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ This will ask you a few questions about your project and generate a new project

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

> 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 create-react-native-library@0.49.8 awesome-library`.

## Local library

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,39 +261,33 @@ export default async function generateExampleApp({
'android.enableJetifier=false'
);

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

await fs.writeFile(
path.join(directory, 'ios', 'Podfile'),
"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile
);
await fs.writeFile(
path.join(directory, 'ios', 'Podfile'),
"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\n\n" + podfile
);

// Android
// Make sure newArchEnabled=true is present in android/gradle.properties
if (gradleProperties.split('\n').includes('#newArchEnabled=true')) {
gradleProperties = gradleProperties.replace(
'#newArchEnabled=true',
'newArchEnabled=true'
);
} else if (
gradleProperties.split('\n').includes('newArchEnabled=false')
) {
gradleProperties = gradleProperties.replace(
'newArchEnabled=false',
'newArchEnabled=true'
);
} else if (
!gradleProperties.split('\n').includes('newArchEnabled=true')
) {
gradleProperties += '\nnewArchEnabled=true';
}
// Android
// Make sure newArchEnabled=true is present in android/gradle.properties
if (gradleProperties.split('\n').includes('#newArchEnabled=true')) {
gradleProperties = gradleProperties.replace(
'#newArchEnabled=true',
'newArchEnabled=true'
);
} else if (gradleProperties.split('\n').includes('newArchEnabled=false')) {
gradleProperties = gradleProperties.replace(
'newArchEnabled=false',
'newArchEnabled=true'
);
} else if (!gradleProperties.split('\n').includes('newArchEnabled=true')) {
gradleProperties += '\nnewArchEnabled=true';
}

await fs.writeFile(
Expand Down
24 changes: 3 additions & 21 deletions packages/create-react-native-library/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ export type ArgName =
| 'example'
| 'reactNativeVersion';

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

export type ProjectType =
| 'turbo-module'
| 'fabric-view'
| 'legacy-module'
| 'legacy-view'
| 'nitro-module'
| 'library';

Expand All @@ -36,17 +34,12 @@ const LANGUAGE_CHOICES: {
{
title: 'Kotlin & Swift',
value: 'kotlin-swift',
types: ['nitro-module', 'legacy-module', 'legacy-view'],
types: ['nitro-module'],
},
{
title: 'Kotlin & Objective-C',
value: 'kotlin-objc',
types: ['turbo-module', 'fabric-view', 'legacy-module', 'legacy-view'],
},
{
title: 'C++ for Android & iOS',
value: 'cpp',
types: ['turbo-module', 'legacy-module'],
types: ['turbo-module', 'fabric-view'],
},
{
title: 'JavaScript for Android, iOS & Web',
Expand Down Expand Up @@ -101,16 +94,6 @@ const TYPE_CHOICES: {
description:
'type-safe, fast integration for native APIs to JS (experimental)',
},
{
title: 'Legacy Native module',
value: 'legacy-module',
description: 'bridge for native APIs to JS (old architecture)',
},
{
title: 'Legacy Native view',
value: 'legacy-view',
description: 'bridge for native views to JS (old architecture)',
},
{
title: 'JavaScript library',
value: 'library',
Expand Down Expand Up @@ -167,7 +150,6 @@ export const acceptedArgs: Record<ArgName, yargs.Options> = {
} as const;

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

export type Answers = {
Expand Down
Loading
Loading