Skip to content

Commit f89fd66

Browse files
fix: fix build:ios/android commands in test-app example (#585)
<!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Summary In #572 we've introduced `test-app` as an option for `example` project, and CRNL contains two scripts `build:ios` and `build:android` that are injected when creating project, RNTA also contains two scripts named in the same way, which are then replaced - in this Pull Request in relevant scenario I added logic which joins two scripts. ### Test plan 1. Create a new project with `create-react-native-library` 2. Choose `test-app` for `example/` 3. `build:ios` and `build:android` should contain logic of creating and bundling app as well as building app with relevant options.
1 parent e7e7c0d commit f89fd66

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,28 @@ export default async function generateExampleApp({
146146
'build:ios': `react-native build-ios --scheme ${projectName}Example --mode Debug --extra-params "-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"`,
147147
};
148148

149-
if (type !== 'expo') {
149+
if (type === 'vanilla') {
150150
Object.assign(scripts, SCRIPTS_TO_ADD);
151+
} else if (type === 'test-app') {
152+
// `react-native-test-app` doesn't bundle application by default in 'Release' mode and also `bundle` command doesn't create a directory.
153+
// `mkdist` script should be removed after stable React Native major contains this fix: https://github.com/facebook/react-native/pull/45182.
154+
155+
const androidBuild = [
156+
'npm run mkdist',
157+
'react-native bundle --entry-file index.js --platform android --dev true --bundle-output dist/main.android.jsbundle --assets-dest dist',
158+
SCRIPTS_TO_ADD['build:android'],
159+
].join(' && ');
160+
161+
const iosBuild = [
162+
'npm run mkdist',
163+
'react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist',
164+
SCRIPTS_TO_ADD['build:android'],
165+
].join(' && ');
166+
167+
Object.assign(scripts, {
168+
'build:android': androidBuild,
169+
'build:ios': iosBuild,
170+
});
151171
}
152172

153173
PACKAGES_TO_REMOVE.forEach((name) => {

0 commit comments

Comments
 (0)