Remove run Metro hook from Xcode build, remove launchPackager scripts (#38242)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38242

See proposal: https://github.com/react-native-community/discussions-and-proposals/discussions/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
This commit is contained in:
Alex Hunt
2023-07-10 05:49:00 -07:00
committed by Facebook GitHub Bot
parent 20dba39dab
commit dc6845739e
6 changed files with 0 additions and 85 deletions
-2
View File
@@ -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",
@@ -1 +0,0 @@
export RCT_METRO_PORT=8081
@@ -1,12 +0,0 @@
:: Copyright (c) Meta Platforms, Inc. and affiliates.
::
:: This source code is licensed under the MIT license found in the
:: LICENSE file in the root directory of this source tree.
@echo off
title Metro
call .packager.bat
cd ../../../
node "%~dp0..\cli.js" start
pause
exit
@@ -1,34 +0,0 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# Set terminal title
echo -en "\\033]0;Metro\\a"
clear
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
export PODS_ROOT="$THIS_DIR/../../../ios/Pods"
WITH_ENVIRONMENT="$THIS_DIR/xcode/with-environment.sh"
source $WITH_ENVIRONMENT
# export packager environment variables
source "$THIS_DIR/.packager.env"
if [ -n "${RCT_PACKAGER_LOGS_DIR}" ] ; then
echo "Writing logs to $RCT_PACKAGER_LOGS_DIR"
# shellcheck source=/dev/null
RCT_PACKAGER_LOG_PATH="$RCT_PACKAGER_LOGS_DIR/metro.log" \
. "$THIS_DIR/packager.sh" \
> "$RCT_PACKAGER_LOGS_DIR/packager.stdout.log" \
2> "$RCT_PACKAGER_LOGS_DIR/packager.stderr.log"
else
# shellcheck source=/dev/null
. "$THIS_DIR/packager.sh"
fi
if [[ -z "$CI" ]]; then
echo "Process terminated. Press <enter> to close the window"
read -r
fi
@@ -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 */,
@@ -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 */
@@ -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 */,
@@ -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;