React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
Memory: 3.11 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.8.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.4
At some point through my iOS "journey", I must have disabled launching the packager. I think this happened at the same time I started linking react native exclusively through Pods. As a result, I have _no_ React libs imported into the xcode project manually. I got rid of all of that and did it all through Pods, which has been working _much_ better for linking other libraries!
Anyways, when I did that, it stopped launching the packager, so now I have to do it manually. I suppose I'm wondering A) how do I turn that back on? and B) is it possible the CLI should check and launch the packager itself if it was not launched during the build process?
cc @lucasbento as he's working on similar field in #310. Feel free to check it out and suggest improvements!
@noahtallen: thanks for opening this issue!
By _doesn't always_ do you mean that it launches the packager sometimes and other times not?
Would you be able to provide a small repo with a code that I can reproduce locally?
I'll try to create a repo for that! No, I'm sorry for the poor phrasing. It never launches the packager for iOS ewhen running from xcode or from the cli. It does launch for Android.
Noah
On Apr 15, 2019 at 2:44 AM,
@noahtallen (https://github.com/noahtallen): thanks for opening this issue!
By doesn't always do you mean that it launches the packager sometimes and other times not?
Would you be able to provide a small repo with a code that I can reproduce locally?
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (https://github.com/react-native-community/cli/issues/317#issuecomment-483127366), or mute the thread (https://github.com/notifications/unsubscribe-auth/AF-cd5W9DVZ2Mj8chq9vFc6h7SW3Jnzyks5vhB_HgaJpZM4cuzew).
@noahtallen: alright, I'll wait for the project then.
Howdy! Here's a repo reproducing the issue: test-react-native-packager. Please let me know if you have any questions. You should be able to see instructions in the readme. The rational behind removing the manually linked react is that I got _so_ many build errors conflicting with other Pods and whatnot when I had it linked _both_ ways! Having it this way has really reduced the amount of friction our team has when working with third party dependencies. If I'm not wrong, this is how it would be set up if one was adding react-native to an existing iOS project.
@noahtallen: cool, I'll check it out!
@noahtallen: FYI I see that you mentioned that you couldn't build it, I updated my local cocoapods to 1.6.1 and did this to get it to run: https://github.com/CocoaPods/CocoaPods/issues/8091#issuecomment-421538684.
So, as per what I can see this is because the target React on Pods doesn't have a start packager build phase as it does when you use it without pods.


I believe I can include the script to start the packager here by doing something like https://stackoverflow.com/a/20505234/4252781, I don't have much experience with this so I am not sure.
@thymikee / @grabbou would you be able to point someone that can check if this is the right thing to do or not?
cc @alloy @orta our lovely CocoaPods experts! :)
The file React.podspec will want that script adding via script_phases key ๐
I was thinking we could do it as a part of new autolinking supporting
build phases. We could then tell React Native to declare it just like any
other dep.
On Wed, 17 Apr 2019 at 22:06, Orta notifications@github.com wrote:
The file React.podspec will want that script adding via script_phases
https://guides.cocoapods.org/syntax/podspec.html#script_phases key ๐โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/react-native-community/cli/issues/317#issuecomment-484240980,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AASZZRXQN3HQXNTWBTPYBELPQ57LLANCNFSM4HF3G6YA
.
That can work, you can see how the support works here: https://github.com/react-native-community/cli/blob/master/packages/platform-ios/native_modules.rb#L43-L62
I should get some docs on this out
I tried to investigate more of this but I don't really understand how this would fit in the autolinking, I'll be waiting for @orta's docs.
Also having this issue after linking react native exclusively with Cocoapods during 0.59.5 update. In our case the issue is ALWAYS occurring in Debug. So please change the title of the issue as @noahtallen confirmed it is the same for him.
I found a workaround:
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env"
if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then
if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then
if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then
echo "warning: Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly"
exit 2
fi
else
open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "warning: Can't start packager automatically"
fi
fi
I tried to put the meat of the issue in the title ;) @ou2s
So, as per what I can see this is because the target
ReactonPodsdoesn't have a start packager build phase as it does when you use it without pods.Without pods
With pods
I believe I can include the script to start the packager here by doing something like https://stackoverflow.com/a/20505234/4252781, I don't have much experience with this so I am not sure.
@thymikee / @grabbou would you be able to point someone that can check if this is the right thing to do or not?
I had a problem after upgrade to RN 0.60 - The packager wasn't starting
Using your package script I have managed to run it ! :)
Yep, I can confirm moving the script into your app target's build phases is the right thing to do
I think the react-native upgrade tool would need to add support for checking that there are no build phases which start the package
@orta said:
Yep, I can confirm moving the script into your app target's build phases is the right thing to do
Ah, OK, thanks, I've managed to do that (https://github.com/zulip/zulip-mobile/commit/33f4b41c8fe628fcb2ece4fcbbc107968c5073d1).
@lucasbento said:
So, as per what I can see this is because the target
ReactonPodsdoesn't have a start packager build phase as it does when you use it without pods.
That sounds right. I'm seeing the same as what's in those screenshots.
Hmm, so, a solution like this one โ
@orta said:
The file
React.podspecwill want that script adding viascript_phaseskey ๐
โ isn't being considered anymore, it sounds like. (Why, I wonder?)
IIUC, though, doesn't that mean that improvements like https://github.com/facebook/react-native/commit/4ea62041118fb031d7540726df2d29185c6b130d have no effect for people on RN v0.60.0 and above, where v0.60.0 is the version when CocoaPods is newly officially favored? At least, not unless people manually update the script in their own app target's build phases? These changes (some also new in v0.60) are hard to keep up with, as they don't appear in rn-diff-purge or the comments in the upgrade helper.
I said:
they don't appear in
rn-diff-purgeor the comments in the upgrade helper.
See also my post in Upgrade Support, at https://github.com/react-native-community/upgrade-support/issues/76.
Also having this issue after linking react native exclusively with Cocoapods during 0.59.5 update. In our case the issue is ALWAYS occurring in Debug. So please change the title of the issue as @noahtallen confirmed it is the same for him.
I found a workaround:
- Add manually the Build Phase script and change the path of the launchPackager.command. Below you'll find the modified script
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}" echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env" if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then echo "warning: Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly" exit 2 fi else open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "warning: Can't start packager automatically" fi fi
Hi everyone,
I've added this script to the app Build Phases (as @orta suggested) -> Run Script but see no change.
Is there something else to do to make the packager start automatically?

Also having this issue after linking react native exclusively with Cocoapods during 0.59.5 update. In our case the issue is ALWAYS occurring in Debug. So please change the title of the issue as @noahtallen confirmed it is the same for him.
I found a workaround:
- Add manually the Build Phase script and change the path of the launchPackager.command. Below you'll find the modified script
export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}" echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env" if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then echo "warning: Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly" exit 2 fi else open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "warning: Can't start packager automatically" fi fiHi everyone,
I've added this script to the app Build Phases (as @orta suggested) -> Run Script but see no change.
Is there something else to do to make the packager start automatically?
uncheck "For install builds only"
Most helpful comment
Also having this issue after linking react native exclusively with Cocoapods during 0.59.5 update. In our case the issue is ALWAYS occurring in Debug. So please change the title of the issue as @noahtallen confirmed it is the same for him.
I found a workaround: