From c61bb71c5e0e1563a3e541261d20c658aa697a80 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Thu, 27 Jun 2024 16:47:48 +0200 Subject: [PATCH 1/8] feat!: use `react-native-test-app` in default `example/` app --- .../src/utils/generateExampleApp.ts | 20 +++++++++++-------- .../example/react-native.config.js | 9 +++++++++ .../example/react-native.config.js | 9 +++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/create-react-native-library/src/utils/generateExampleApp.ts b/packages/create-react-native-library/src/utils/generateExampleApp.ts index 7f44ad5d0..0525c93f6 100644 --- a/packages/create-react-native-library/src/utils/generateExampleApp.ts +++ b/packages/create-react-native-library/src/utils/generateExampleApp.ts @@ -65,17 +65,22 @@ export default async function generateExampleApp({ const directory = path.join(dest, 'example'); const args = type === 'native' - ? // `npx react-native init --directory example --skip-install` + ? // `npx --package react-native-test-app@latest init --name ${projectName}Example --destination example --version ${reactNativeVersion}` [ - 'react-native@latest', + '--package', + `react-native-test-app@latest`, 'init', + '--name', `${projectName}Example`, - '--directory', + `--destination`, directory, - '--version', - reactNativeVersion, - '--skip-install', - '--npm', + ...(reactNativeVersion !== 'latest' + ? ['--version', reactNativeVersion] + : []), + '--platform', + 'ios', + '--platform', + 'android', ] : // `npx create-expo-app example --no-install --template blank` [ @@ -87,7 +92,6 @@ export default async function generateExampleApp({ ]; await spawn('npx', args, { - cwd: dest, env: { ...process.env, npm_config_yes: 'true' }, }); diff --git a/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js b/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js index a5166956f..0416691b4 100644 --- a/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js +++ b/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js @@ -1,7 +1,16 @@ const path = require('path'); const pak = require('../package.json'); +const { configureProjects } = require('react-native-test-app'); module.exports = { + project: configureProjects({ + android: { + sourceDir: 'android', + }, + ios: { + sourceDir: 'ios', + }, + }), dependencies: { [pak.name]: { root: path.join(__dirname, '..'), diff --git a/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js b/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js index a5166956f..0416691b4 100644 --- a/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js +++ b/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js @@ -1,7 +1,16 @@ const path = require('path'); const pak = require('../package.json'); +const { configureProjects } = require('react-native-test-app'); module.exports = { + project: configureProjects({ + android: { + sourceDir: 'android', + }, + ios: { + sourceDir: 'ios', + }, + }), dependencies: { [pak.name]: { root: path.join(__dirname, '..'), From c53fbb745bd4c659e28594f785c463c4dc4158d6 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Thu, 27 Jun 2024 17:25:40 +0200 Subject: [PATCH 2/8] feat: allow providing example type via `--example` flag --- .../create-react-native-library/src/index.ts | 33 ++++--- .../src/utils/generateExampleApp.ts | 90 ++++++++++++------- 2 files changed, 81 insertions(+), 42 deletions(-) diff --git a/packages/create-react-native-library/src/index.ts b/packages/create-react-native-library/src/index.ts index c72ad435e..02c0cf9cc 100644 --- a/packages/create-react-native-library/src/index.ts +++ b/packages/create-react-native-library/src/index.ts @@ -139,11 +139,17 @@ type Answers = { repoUrl: string; languages: ProjectLanguages; type?: ProjectType; - example?: boolean; + example?: ExampleType; reactNativeVersion?: string; withRecommendedOptions?: boolean; }; +export enum ExampleType { + Vanilla = 'vanilla', + TestApp = 'test-app', + Expo = 'expo', +} + const LANGUAGE_CHOICES: { title: string; value: ProjectLanguages; @@ -273,9 +279,10 @@ const args: Record = { type: 'boolean', }, 'example': { - description: 'Whether to create an example app', - type: 'boolean', - default: true, + description: 'Type of the app to create', + type: 'string', + choices: ['vanilla', 'test-app'], + default: 'vanilla', }, 'with-recommended-options': { description: `Whether to use the recommended template. ${RECOMMENDED_TEMPLATE.description}`, @@ -632,7 +639,11 @@ async function create(argv: yargs.Arguments) { : 'legacy'; const example = - hasExample && !local ? (type === 'library' ? 'expo' : 'native') : 'none'; + hasExample && !local + ? type === 'library' + ? ExampleType.Expo + : hasExample + : null; const project = slug.replace(/^(react-native-|@[^/]+\/)/, ''); @@ -718,7 +729,7 @@ async function create(argv: yargs.Arguments) { await fs.mkdirp(folder); if (reactNativeVersion != null) { - if (example === 'expo') { + if (example === ExampleType.Expo) { console.warn( `${kleur.yellow('⚠')} Ignoring --react-native-version for Expo example` ); @@ -733,7 +744,7 @@ async function create(argv: yargs.Arguments) { const spinner = ora().start(); - if (example !== 'none') { + if (example) { spinner.text = 'Generating example app'; await generateExampleApp({ @@ -753,7 +764,7 @@ async function create(argv: yargs.Arguments) { } else { await copyDir(COMMON_FILES, folder); - if (example !== 'none') { + if (example) { await copyDir(COMMON_EXAMPLE_FILES, folder); } } @@ -762,7 +773,7 @@ async function create(argv: yargs.Arguments) { await copyDir(JS_FILES, folder); await copyDir(EXPO_FILES, folder); } else { - if (example !== 'none') { + if (example) { await copyDir( path.join(EXAMPLE_FILES, 'example'), path.join(folder, 'example') @@ -771,7 +782,7 @@ async function create(argv: yargs.Arguments) { await copyDir(NATIVE_COMMON_FILES, folder); - if (example !== 'none') { + if (example) { await copyDir(NATIVE_COMMON_EXAMPLE_FILES, folder); } @@ -794,7 +805,7 @@ async function create(argv: yargs.Arguments) { } } - if (example !== 'none') { + if (example) { // Set `react` and `react-native` versions of root `package.json` from example `package.json` const examplePackageJson = await fs.readJSON( path.join(folder, 'example', 'package.json') diff --git a/packages/create-react-native-library/src/utils/generateExampleApp.ts b/packages/create-react-native-library/src/utils/generateExampleApp.ts index 0525c93f6..07b5d8136 100644 --- a/packages/create-react-native-library/src/utils/generateExampleApp.ts +++ b/packages/create-react-native-library/src/utils/generateExampleApp.ts @@ -2,6 +2,7 @@ import fs from 'fs-extra'; import path from 'path'; import https from 'https'; import { spawn } from './spawn'; +import { ExampleType } from './../index'; const FILES_TO_DELETE = [ '__tests__', @@ -55,7 +56,7 @@ export default async function generateExampleApp({ arch, reactNativeVersion = 'latest', }: { - type: 'expo' | 'native'; + type: ExampleType; dest: string; slug: string; projectName: string; @@ -63,33 +64,60 @@ export default async function generateExampleApp({ reactNativeVersion?: string; }) { const directory = path.join(dest, 'example'); - const args = - type === 'native' - ? // `npx --package react-native-test-app@latest init --name ${projectName}Example --destination example --version ${reactNativeVersion}` - [ - '--package', - `react-native-test-app@latest`, - 'init', - '--name', - `${projectName}Example`, - `--destination`, - directory, - ...(reactNativeVersion !== 'latest' - ? ['--version', reactNativeVersion] - : []), - '--platform', - 'ios', - '--platform', - 'android', - ] - : // `npx create-expo-app example --no-install --template blank` - [ - 'create-expo-app@latest', - directory, - '--no-install', - '--template', - 'blank', - ]; + + // `npx --package react-native-test-app@latest init --name ${projectName}Example --destination example --version ${reactNativeVersion}` + const testAppArgs = [ + '--package', + `react-native-test-app@latest`, + 'init', + '--name', + `${projectName}Example`, + `--destination`, + directory, + ...(reactNativeVersion !== 'latest' + ? ['--version', reactNativeVersion] + : []), + '--platform', + 'ios', + '--platform', + 'android', + ]; + + // `npx react-native init --directory example --skip-install` + const vanillaArgs = [ + 'react-native@latest', + 'init', + `${projectName}Example`, + '--directory', + directory, + '--version', + reactNativeVersion, + '--skip-install', + '--npm', + ]; + + // `npx create-expo-app example --no-install --template blank` + const expoArgs = [ + 'create-expo-app@latest', + directory, + '--no-install', + '--template', + 'blank', + ]; + + let args: string[] = []; + + switch (type) { + case ExampleType.Vanilla: + args = vanillaArgs; + break; + case ExampleType.TestApp: + args = testAppArgs; + break; + case ExampleType.Expo: + args = expoArgs; + break; + } await spawn('npx', args, { env: { ...process.env, npm_config_yes: 'true' }, @@ -121,7 +149,7 @@ export default async function generateExampleApp({ 'build:ios': `cd ios && xcodebuild -workspace ${projectName}Example.xcworkspace -scheme ${projectName}Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO`, }; - if (type === 'native') { + if (type !== ExampleType.Expo) { Object.assign(scripts, SCRIPTS_TO_ADD); } @@ -132,7 +160,7 @@ export default async function generateExampleApp({ Object.assign(devDependencies, PACKAGES_TO_ADD_DEV); - if (type === 'expo') { + if (type === ExampleType.Expo) { const sdkVersion = dependencies.expo.split('.')[0].replace(/[^\d]/, ''); let bundledNativeModules: Record; @@ -176,7 +204,7 @@ export default async function generateExampleApp({ spaces: 2, }); - if (type === 'native') { + if (type !== ExampleType.Expo) { let gradleProperties = await fs.readFile( path.join(directory, 'android', 'gradle.properties'), 'utf8' From 6a2f3daeb8f9a4eee390136a13dd8175cab19ddf Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Thu, 27 Jun 2024 17:33:50 +0200 Subject: [PATCH 3/8] fix: convert `enum` to union type --- packages/create-react-native-library/src/index.ts | 14 +++----------- .../src/utils/generateExampleApp.ts | 14 +++++++------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/packages/create-react-native-library/src/index.ts b/packages/create-react-native-library/src/index.ts index 02c0cf9cc..12a227c93 100644 --- a/packages/create-react-native-library/src/index.ts +++ b/packages/create-react-native-library/src/index.ts @@ -144,11 +144,7 @@ type Answers = { withRecommendedOptions?: boolean; }; -export enum ExampleType { - Vanilla = 'vanilla', - TestApp = 'test-app', - Expo = 'expo', -} +export type ExampleType = 'vanilla' | 'test-app' | 'expo'; const LANGUAGE_CHOICES: { title: string; @@ -639,11 +635,7 @@ async function create(argv: yargs.Arguments) { : 'legacy'; const example = - hasExample && !local - ? type === 'library' - ? ExampleType.Expo - : hasExample - : null; + hasExample && !local ? (type === 'library' ? 'expo' : hasExample) : null; const project = slug.replace(/^(react-native-|@[^/]+\/)/, ''); @@ -729,7 +721,7 @@ async function create(argv: yargs.Arguments) { await fs.mkdirp(folder); if (reactNativeVersion != null) { - if (example === ExampleType.Expo) { + if (example === 'expo') { console.warn( `${kleur.yellow('⚠')} Ignoring --react-native-version for Expo example` ); diff --git a/packages/create-react-native-library/src/utils/generateExampleApp.ts b/packages/create-react-native-library/src/utils/generateExampleApp.ts index 07b5d8136..56398580c 100644 --- a/packages/create-react-native-library/src/utils/generateExampleApp.ts +++ b/packages/create-react-native-library/src/utils/generateExampleApp.ts @@ -2,7 +2,7 @@ import fs from 'fs-extra'; import path from 'path'; import https from 'https'; import { spawn } from './spawn'; -import { ExampleType } from './../index'; +import type { ExampleType } from './../index'; const FILES_TO_DELETE = [ '__tests__', @@ -108,13 +108,13 @@ export default async function generateExampleApp({ let args: string[] = []; switch (type) { - case ExampleType.Vanilla: + case 'vanilla': args = vanillaArgs; break; - case ExampleType.TestApp: + case 'test-app': args = testAppArgs; break; - case ExampleType.Expo: + case 'expo': args = expoArgs; break; } @@ -149,7 +149,7 @@ export default async function generateExampleApp({ 'build:ios': `cd ios && xcodebuild -workspace ${projectName}Example.xcworkspace -scheme ${projectName}Example -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO`, }; - if (type !== ExampleType.Expo) { + if (type !== 'expo') { Object.assign(scripts, SCRIPTS_TO_ADD); } @@ -160,7 +160,7 @@ export default async function generateExampleApp({ Object.assign(devDependencies, PACKAGES_TO_ADD_DEV); - if (type === ExampleType.Expo) { + if (type === 'expo') { const sdkVersion = dependencies.expo.split('.')[0].replace(/[^\d]/, ''); let bundledNativeModules: Record; @@ -204,7 +204,7 @@ export default async function generateExampleApp({ spaces: 2, }); - if (type !== ExampleType.Expo) { + if (type !== 'expo') { let gradleProperties = await fs.readFile( path.join(directory, 'android', 'gradle.properties'), 'utf8' From 5a70b276b6feca3734de8afce8dc6ed2cf83c366 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 1 Jul 2024 17:21:02 +0200 Subject: [PATCH 4/8] fix: add `react-native-test-app` specific config conditionally --- .../native-common-example/example/react-native.config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js b/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js index 0416691b4..3dc08e6f0 100644 --- a/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js +++ b/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js @@ -1,8 +1,11 @@ const path = require('path'); const pak = require('../package.json'); +<% if (example === 'test-app') { -%> const { configureProjects } = require('react-native-test-app'); +<% } -%> module.exports = { +<% if (example === 'test-app') { -%> project: configureProjects({ android: { sourceDir: 'android', @@ -11,6 +14,7 @@ module.exports = { sourceDir: 'ios', }, }), +<% } -%> dependencies: { [pak.name]: { root: path.join(__dirname, '..'), From ef0953b0c7e25dec0a45578dc27e043592093ff3 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Wed, 3 Jul 2024 13:54:49 +0200 Subject: [PATCH 5/8] fix: properly handle example argument --- .../create-react-native-library/src/index.ts | 145 ++++++++++++------ 1 file changed, 94 insertions(+), 51 deletions(-) diff --git a/packages/create-react-native-library/src/index.ts b/packages/create-react-native-library/src/index.ts index 869247956..fd5951878 100644 --- a/packages/create-react-native-library/src/index.ts +++ b/packages/create-react-native-library/src/index.ts @@ -217,6 +217,24 @@ const TYPE_CHOICES: { }, ]; +const EXAMPLE_CHOICES = [ + { + title: 'Test app', + value: 'test-app', + description: "app's native code is abstracted away", + }, + { + title: 'Vanilla', + value: 'vanilla', + description: "provides access to app's native code", + }, + { + title: 'Expo', + value: 'expo', + description: 'managed expo project with web support', + }, +] as const; + const args: Record = { 'slug': { description: 'Name of the npm package', @@ -261,8 +279,7 @@ const args: Record = { 'example': { description: 'Type of the app to create', type: 'string', - choices: ['vanilla', 'test-app'], - default: 'vanilla', + choices: EXAMPLE_CHOICES.map(({ value }) => value), }, }; @@ -451,64 +468,78 @@ async function create(argv: yargs.Arguments) { }); }, }, - }; - - // Validate arguments passed to the CLI - for (const [key, value] of Object.entries(argv)) { - if (value == null) { - continue; - } + 'example': { + type: 'select', + name: 'example', + message: 'What type of example app do you want to create?', + choices: (_, values) => { + return EXAMPLE_CHOICES.filter((choice) => { + if (values.type) { + return values.type === 'library' + ? choice.value === 'expo' + : choice.value !== 'expo'; + } - const question = questions[key as ArgName]; + return true; + }); + }, + }, + }; - if (question == null) { - continue; - } + const validate = (answers: Answers) => { + for (const [key, value] of Object.entries(answers)) { + if (value == null) { + continue; + } - let valid = question.validate ? question.validate(String(value)) : true; + const question = questions[key as ArgName]; - // We also need to guard against invalid choices - // If we don't already have a validation message to provide a better error - if (typeof valid !== 'string' && 'choices' in question) { - const choices = - typeof question.choices === 'function' - ? question.choices(undefined, argv, question) - : question.choices; + if (question == null) { + continue; + } - if (choices && !choices.some((choice) => choice.value === value)) { - valid = `Supported values are - ${choices.map((c) => - kleur.green(c.value) - )}`; + let valid = question.validate ? question.validate(String(value)) : true; + + // We also need to guard against invalid choices + // If we don't already have a validation message to provide a better error + if (typeof valid !== 'string' && 'choices' in question) { + const choices = + typeof question.choices === 'function' + ? question.choices( + undefined, + // @ts-expect-error: it complains about optional values, but it should be fine + answers, + question + ) + : question.choices; + + if (choices && !choices.some((choice) => choice.value === value)) { + valid = `Supported values are - ${choices + .map((c) => kleur.green(c.value)) + .join(', ')}`; + } } - } - if (valid !== true) { - let message = `Invalid value ${kleur.red( - String(value) - )} passed for ${kleur.blue(key)}`; + if (valid !== true) { + let message = `Invalid value ${kleur.red( + String(value) + )} passed for ${kleur.blue(key)}`; - if (typeof valid === 'string') { - message += `: ${valid}`; - } + if (typeof valid === 'string') { + message += `: ${valid}`; + } - console.log(message); + console.log(message); - process.exit(1); + process.exit(1); + } } - } + }; - const { - slug, - description, - authorName, - authorEmail, - authorUrl, - repoUrl, - type = 'module-mixed', - languages = type === 'library' ? 'js' : 'java-objc', - example: hasExample, - reactNativeVersion, - } = { + // Validate arguments passed to the CLI + validate(argv); + + const answers = { ...argv, ...(await prompts( Object.entries(questions) @@ -557,6 +588,21 @@ async function create(argv: yargs.Arguments) { )), } as Answers; + validate(answers); + + const { + slug, + description, + authorName, + authorEmail, + authorUrl, + repoUrl, + type = 'module-mixed', + languages = type === 'library' ? 'js' : 'java-objc', + example = local ? null : type === 'library' ? 'expo' : 'test-app', + reactNativeVersion, + } = answers; + // Get latest version of Bob from NPM let version: string; @@ -580,9 +626,6 @@ async function create(argv: yargs.Arguments) { ? 'mixed' : 'legacy'; - const example = - hasExample && !local ? (type === 'library' ? 'expo' : hasExample) : null; - const project = slug.replace(/^(react-native-|@[^/]+\/)/, ''); let namespace: string | undefined; From fa526032e7fbe416c5744d13424424f8ec416416 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Wed, 3 Jul 2024 14:01:06 +0200 Subject: [PATCH 6/8] ci: fix ci to use the example argument --- .github/workflows/build-templates.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-templates.yml b/.github/workflows/build-templates.yml index c2dde503c..37733abe9 100644 --- a/.github/workflows/build-templates.yml +++ b/.github/workflows/build-templates.yml @@ -116,6 +116,7 @@ jobs: --repo-url https://test.test \ --type ${{ matrix.type }} \ --languages ${{ matrix.language }} \ + --example ${{ matrix.language == 'js' && 'expo' || 'vanilla' }} \ --no-local - name: Cache dependencies of library From 54d13ea0016378a17279f5a330b5542b1d9ce6b3 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Wed, 3 Jul 2024 14:37:54 +0200 Subject: [PATCH 7/8] fix: fix incorrect conditions for example --- .../templates/common/$package.json | 8 ++++---- .../templates/native-common-example/turbo.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/create-react-native-library/templates/common/$package.json b/packages/create-react-native-library/templates/common/$package.json index 5cf2ca060..f4b536505 100644 --- a/packages/create-react-native-library/templates/common/$package.json +++ b/packages/create-react-native-library/templates/common/$package.json @@ -26,13 +26,13 @@ "!**/.*" ], "scripts": { -<% if (example !== 'none') { -%> +<% if (example) { -%> "example": "yarn workspace <%- project.slug -%>-example", <% } -%> "test": "jest", "typecheck": "tsc --noEmit", "lint": "eslint \"**/*.{js,ts,tsx}\"", -<% if (example === 'native') { -%> +<% if (example !== 'expo') { -%> "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib", <% } else { -%> "clean": "del-cli lib", @@ -76,7 +76,7 @@ "react-native": "0.73.0", "react-native-builder-bob": "^<%- bob.version %>", "release-it": "^15.0.0", -<% if (example === 'native') { -%> +<% if (example !== 'expo') { -%> "turbo": "^1.10.7", <% } -%> "typescript": "^5.2.2" @@ -88,7 +88,7 @@ "react": "*", "react-native": "*" }, -<% if (example !== 'none') { -%> +<% if (example) { -%> "workspaces": [ "example" ], diff --git a/packages/create-react-native-library/templates/native-common-example/turbo.json b/packages/create-react-native-library/templates/native-common-example/turbo.json index 385880056..380df843a 100644 --- a/packages/create-react-native-library/templates/native-common-example/turbo.json +++ b/packages/create-react-native-library/templates/native-common-example/turbo.json @@ -1,7 +1,7 @@ { "$schema": "https://turbo.build/schema.json", "pipeline": { -<% if (example === 'native') { -%> +<% if (example !== 'expo') { -%> "build:android": { "inputs": [ "package.json", From 6f977e5b308e66cc238951a51a0de06cdd209179 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Wed, 3 Jul 2024 14:56:32 +0200 Subject: [PATCH 8/8] fix: enable automatic pod installation --- .../example-legacy/example/react-native.config.js | 11 +++++++++++ .../example/react-native.config.js | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js b/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js index 0416691b4..c1d96d3c6 100644 --- a/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js +++ b/packages/create-react-native-library/templates/example-legacy/example/react-native.config.js @@ -1,16 +1,27 @@ const path = require('path'); const pak = require('../package.json'); +<% if (example === 'test-app') { -%> const { configureProjects } = require('react-native-test-app'); +<% } -%> module.exports = { +<% if (example === 'test-app') { -%> project: configureProjects({ android: { sourceDir: 'android', }, ios: { sourceDir: 'ios', + automaticPodsInstallation: true, }, }), +<% } else { -%> + project: { + ios: { + automaticPodsInstallation: true, + }, + }, +<% } -%> dependencies: { [pak.name]: { root: path.join(__dirname, '..'), diff --git a/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js b/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js index 3dc08e6f0..c1d96d3c6 100644 --- a/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js +++ b/packages/create-react-native-library/templates/native-common-example/example/react-native.config.js @@ -12,8 +12,15 @@ module.exports = { }, ios: { sourceDir: 'ios', + automaticPodsInstallation: true, }, }), +<% } else { -%> + project: { + ios: { + automaticPodsInstallation: true, + }, + }, <% } -%> dependencies: { [pak.name]: {