diff --git a/Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj b/Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj index 8121ed0c108179..efb2609ad37b1a 100644 --- a/Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj +++ b/Libraries/WebSocket/RCTWebSocket.xcodeproj/project.pbxproj @@ -435,8 +435,8 @@ EXECUTABLE_PREFIX = lib; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", + "RCT_METRO_PORT=${RCT_METRO_PORT}", "$(inherited)", - "RCT_METRO_PORT=${RCT_METRO_PORT}", ); GCC_TREAT_WARNINGS_AS_ERRORS = NO; OTHER_LDFLAGS = "-ObjC"; diff --git a/React/Base/RCTDefines.h b/React/Base/RCTDefines.h index f700e0335080fa..0124bf340561db 100644 --- a/React/Base/RCTDefines.h +++ b/React/Base/RCTDefines.h @@ -74,6 +74,23 @@ #define RCT_PROFILE RCT_DEV #endif +/** + * Add the default Metro packager port number + */ +#ifndef RCT_METRO_PORT +#define RCT_METRO_PORT 8081 +#else +// test if RCT_METRO_PORT is empty +#define RCT_METRO_PORT_DO_EXPAND(VAL) VAL ## 1 +#define RCT_METRO_PORT_EXPAND(VAL) RCT_METRO_PORT_DO_EXPAND(VAL) +#if !defined(RCT_METRO_PORT) || (RCT_METRO_PORT_EXPAND(RCT_METRO_PORT) == 1) +// Only here if RCT_METRO_PORT is not defined +// OR RCT_METRO_PORT is the empty string +#undef RCT_METRO_PORT +#define RCT_METRO_PORT 8081 +#endif +#endif + /** * By default, only raise an NSAssertion in debug mode * (custom assert functions will still be called). @@ -99,10 +116,3 @@ _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") \ RCT_EXTERN NSException *_RCTNotImplementedException(SEL, Class); \ method NS_UNAVAILABLE { @throw _RCTNotImplementedException(_cmd, [self class]); } \ _Pragma("clang diagnostic pop") - -/** - * Add the default Metro packager port number - */ -#ifndef RCT_METRO_PORT -#define RCT_METRO_PORT 8081 -#endif diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 7e6ed8c1ec8e8a..a96223df6e0846 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -3957,7 +3957,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - 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"; + 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"; showEnvVarsInLog = 0; }; 142C4F7F1B582EA6001F0B58 /* Include RCTJSCProfiler */ = {