Skip to content

Commit 255a9b5

Browse files
committed
checks for empty RCT_METRO_PORT define and replaces it with default
1 parent e51bf42 commit 255a9b5

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,8 @@
435435
EXECUTABLE_PREFIX = lib;
436436
GCC_PREPROCESSOR_DEFINITIONS = (
437437
"DEBUG=1",
438+
"RCT_METRO_PORT=${RCT_METRO_PORT}",
438439
"$(inherited)",
439-
"RCT_METRO_PORT=${RCT_METRO_PORT}",
440440
);
441441
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
442442
OTHER_LDFLAGS = "-ObjC";

React/Base/RCTDefines.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@
7474
#define RCT_PROFILE RCT_DEV
7575
#endif
7676

77+
/**
78+
* Add the default Metro packager port number
79+
*/
80+
#ifndef RCT_METRO_PORT
81+
#define RCT_METRO_PORT 8081
82+
#else
83+
// test if RCT_METRO_PORT is empty
84+
#define RCT_METRO_PORT_DO_EXPAND(VAL) VAL ## 1
85+
#define RCT_METRO_PORT_EXPAND(VAL) RCT_METRO_PORT_DO_EXPAND(VAL)
86+
#if !defined(RCT_METRO_PORT) || (RCT_METRO_PORT_EXPAND(RCT_METRO_PORT) == 1)
87+
// Only here if RCT_METRO_PORT is not defined
88+
// OR RCT_METRO_PORT is the empty string
89+
#undef RCT_METRO_PORT
90+
#define RCT_METRO_PORT 8081
91+
#endif
92+
#endif
93+
7794
/**
7895
* By default, only raise an NSAssertion in debug mode
7996
* (custom assert functions will still be called).
@@ -99,10 +116,3 @@ _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \
99116
RCT_EXTERN NSException *_RCTNotImplementedException(SEL, Class); \
100117
method NS_UNAVAILABLE { @throw _RCTNotImplementedException(_cmd, [self class]); } \
101118
_Pragma("clang diagnostic pop")
102-
103-
/**
104-
* Add the default Metro packager port number
105-
*/
106-
#ifndef RCT_METRO_PORT
107-
#define RCT_METRO_PORT 8081
108-
#endif

React/React.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3724,7 +3724,7 @@
37243724
);
37253725
runOnlyForDeploymentPostprocessing = 0;
37263726
shellPath = /bin/sh;
3727-
shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:-8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../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/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi";
3727+
shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../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/../scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi";
37283728
showEnvVarsInLog = 0;
37293729
};
37303730
142C4F7F1B582EA6001F0B58 /* Include RCTJSCProfiler */ = {

0 commit comments

Comments
 (0)