-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
adds --port option to react-native run-ios
as well as patches port …
#16172
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh my, it this a standard way to handle this kind of problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shergin good question :) . This is the only way I could find to cleanly handle the empty string dilemma. I thought at first that we could use a bash expansion trick where you say |
||
#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). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3957,7 +3957,7 @@ | |
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
shellPath = /bin/sh; | ||
shellScript = "if [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost 8081 ; then\n if ! curl -s \"http://localhost:8081/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port 8081 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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maaaaaagic... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what this comment means. Would you like me to a comment to the code to explain what is going on here? |
||
showEnvVarsInLog = 0; | ||
}; | ||
142C4F7F1B582EA6001F0B58 /* Include RCTJSCProfiler */ = { | ||
|
@@ -5100,6 +5100,13 @@ | |
buildSettings = { | ||
CLANG_CXX_LANGUAGE_STANDARD = "c++14"; | ||
CLANG_STATIC_ANALYZER_MODE = deep; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RCT_METRO_PORT is passed in as an environment variable to keep the code as clean as possible. I only added the RCT_METRO_PORT, when adding the GCC preprocessor definitions xcode pre-populated the list with the other defines. |
||
"DEBUG=1", | ||
"RCT_DEBUG=1", | ||
"RCT_DEV=1", | ||
"RCT_NSASSERT=1", | ||
"RCT_METRO_PORT=${RCT_METRO_PORT}", | ||
); | ||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES; | ||
OTHER_LDFLAGS = "-ObjC"; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
|
@@ -5114,7 +5121,10 @@ | |
buildSettings = { | ||
CLANG_CXX_LANGUAGE_STANDARD = "c++14"; | ||
CLANG_STATIC_ANALYZER_MODE = deep; | ||
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; | ||
GCC_PREPROCESSOR_DEFINITIONS = ( | ||
"$(inherited)", | ||
"RCT_METRO_PORT=${RCT_METRO_PORT}", | ||
); | ||
GCC_WARN_ABOUT_MISSING_NEWLINE = YES; | ||
OTHER_LDFLAGS = "-ObjC"; | ||
PRODUCT_NAME = "$(TARGET_NAME)"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we add DEBUG here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shergin When I added the GCC preprocessor section in XCode, it was added automatically, likely because this is the
debug
preset (see line 440). My guess is that if you omit the preprocessor section XCode auto-assigns the DEBUG define, but I am no XCode/Objective-C wizard and can't confirm this.