Skip to content

Commit

Permalink
Remove run Metro hook from Xcode build, remove launchPackager scripts (
Browse files Browse the repository at this point in the history
…#38242)

Summary:
Pull Request resolved: #38242

See proposal: react-native-community/discussions-and-proposals#681

**Removed script files**

I searched GitHub (and specifically `react-native-windows/macos`) to confirm these files are not referenced:

- `scripts/launchPackager.bat`
- `scripts/launchPackager.command`
- `scripts/.packager.env`

Interestingly, React Native CLI refers to a `.packager.env` at a different location (`node_modules/.bin/`), and includes modified copies of `launchPackager.command/bat`. This PR removes duplication with these.

Changelog: [iOS][Breaking] Metro will no longer be started when running builds via Xcode

Reviewed By: cortinico

Differential Revision: D47297469

fbshipit-source-id: 06c3602d58b21ed693c3daa763d99947a70bfc5a
  • Loading branch information
huntie authored and facebook-github-bot committed Jul 10, 2023
1 parent 20dba39 commit dc68457
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 85 deletions.
2 changes: 0 additions & 2 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
"scripts/hermes/prepare-hermes-for-build.js",
"scripts/ios-configure-glog.sh",
"scripts/xcode/with-environment.sh",
"scripts/launchPackager.bat",
"scripts/launchPackager.command",
"scripts/native_modules.rb",
"scripts/node-binary.sh",
"scripts/packager.sh",
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/scripts/.packager.env

This file was deleted.

12 changes: 0 additions & 12 deletions packages/react-native/scripts/launchPackager.bat

This file was deleted.

34 changes: 0 additions & 34 deletions packages/react-native/scripts/launchPackager.command

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "HelloWorld" */;
buildPhases = (
C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */,
FD10A7F022414F080027D42C /* Start Packager */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
Expand Down Expand Up @@ -378,25 +377,6 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Start Packager";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
16 changes: 0 additions & 16 deletions packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */,
5CF0FD27207FC6EC00C13D65 /* Start Metro */,
79E8BE2B119D4C5CCD2F04B3 /* [RN] Copy Hermes Framework */,
4E5A5A192F46F13B14A915AF /* [CP] Embed Pods Frameworks */,
4E2AB2EE08A8E6F86E659152 /* [CP] Copy Pods Resources */,
Expand Down Expand Up @@ -627,21 +626,6 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
5CF0FD27207FC6EC00C13D65 /* Start Metro */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Start Metro";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -x\n\n# RN-Tester does not have an iOS directory. The PROJECT_ROOT should \n# point to the folder where the `metro.config.js` file lives.\nexport PROJECT_ROOT=$(pwd)\nexport RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open -n \"$SRCROOT/../react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n";
showEnvVarsInLog = 0;
};
68CD48B71D2BCB2C007E06A9 /* Build JS Bundle */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down

2 comments on commit dc68457

@sosunny
Copy link

Choose a reason for hiding this comment

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

@huntie As you see in #42173, not having metro start when building with XCode has been quite inconvenient. Is there no way to continue supporting this? Thanks!

@NiharR27
Copy link

Choose a reason for hiding this comment

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

+1 what @sosunny said

Please sign in to comment.