Skip to content
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

feat(scripts): Support multiple bundles in react-native-xcode.sh #46339

Closed
wants to merge 2 commits into from

Conversation

fivecar
Copy link
Contributor

@fivecar fivecar commented Sep 5, 2024

Summary:

This enables projects to have multiple bundles built during the Xcode bundling phase (e.g. for projects where you might have a PhoneScene and a CarPlayScene each with their own RootView and bundle, if you're using react-native-carplay).

Changelog:

[IOS] [ADDED] - User-configurable BUNDLE_NAME when building bundles

Test Plan:

Built my project with the following Xcode "Bundle React Native code" build step:

set -e

export SOURCEMAP_FILE="$(pwd)/../main.jsbundle.map";
SOURCEMAP_FILE="$(pwd)/../main.jsbundle.map"

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"

/bin/sh -c "BUNDLE_NAME=main $WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
/bin/sh -c "BUNDLE_NAME=carplay $WITH_ENVIRONMENT $REACT_NATIVE_XCODE"

Then launched the app with a modified AppDelegate.swift which loaded main.jsbundle into one RootView and carplay.bundle into another RootView.

This enables projects to have multiple bundles built during the Xcode bundling phase (e.g. for projects where you might have a PhoneScene and a CarPlayScene each with their own RootView and bundle).
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Sep 5, 2024
@blakef
Copy link
Contributor

blakef commented Sep 6, 2024

cc @cipolleschi thoughts?

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fivecar to work on this.
I left a small suggestion to improve the code readability and maintainability.

packages/react-native/scripts/react-native-xcode.sh Outdated Show resolved Hide resolved
Co-authored-by: Riccardo Cipolleschi <riccardo.cipolleschi@gmail.com>
@fivecar
Copy link
Contributor Author

fivecar commented Sep 12, 2024

Thanks, @cipolleschi! I was the FB LON site lead for its first few years; it's gratifying to have this approved by you. 😄

It looks from the PR that the rest of the workflow needs to be done by maintainers. Please LMK if there's anything else I should be doing on this.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 13, 2024
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in f8287e2.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @fivecar in f8287e2

When will my fix make it into a release? | How to file a pick request?

@fivecar fivecar deleted the allow-multiple-bundles branch September 14, 2024 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants