Skip to content

Commit

Permalink
fix: fix build:ios/android commands in test-app example (#585)
Browse files Browse the repository at this point in the history
<!-- 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.
  • Loading branch information
szymonrybczak authored Jul 5, 2024
1 parent e7e7c0d commit f89fd66
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,28 @@ export default async function generateExampleApp({
'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"`,
};

if (type !== 'expo') {
if (type === 'vanilla') {
Object.assign(scripts, SCRIPTS_TO_ADD);
} else if (type === 'test-app') {
// `react-native-test-app` doesn't bundle application by default in 'Release' mode and also `bundle` command doesn't create a directory.
// `mkdist` script should be removed after stable React Native major contains this fix: https://github.com/facebook/react-native/pull/45182.

const androidBuild = [
'npm run mkdist',
'react-native bundle --entry-file index.js --platform android --dev true --bundle-output dist/main.android.jsbundle --assets-dest dist',
SCRIPTS_TO_ADD['build:android'],
].join(' && ');

const iosBuild = [
'npm run mkdist',
'react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist',
SCRIPTS_TO_ADD['build:android'],
].join(' && ');

Object.assign(scripts, {
'build:android': androidBuild,
'build:ios': iosBuild,
});
}

PACKAGES_TO_REMOVE.forEach((name) => {
Expand Down

0 comments on commit f89fd66

Please sign in to comment.