Aaron Balthaser
Aaron Balthaser

Reputation: 2622

React Native not working after Xcode 10 update

I just upgraded to Xcode 10 and now after attempting to run my existing projects I was met with the below error. After searching I found the following issue when running react native init https://github.com/facebook/react-native/issues/21490. This solution also fixes my issue.

However I am wondering if anyone knows why my current project now require me to run the bundler as a separate instance. It's not the end of the world but it's certainly not the best experience.

Does anyone know of a way the get everything working as it was before without the need to run the following commands:

  1. rm -rf $TMPDIR/react-; rm -rf $TMPDIR/haste-; rm -rf $TMPDIR/metro-*; watchman watch-del-all
  2. react-native start --reset-cache
  3. (separate terminal) react-native run-ios

enter image description here

Upvotes: 1

Views: 2061

Answers (2)

Andrew Schwartz
Andrew Schwartz

Reputation: 1

You may need to add an additional Build Phase to the xCode project after "Bundle React Native code and images"

Add a new build script by selecting the + sign on the top left and selecting "New Run Script Phase" then add the following

if nc -w 5 -z localhost 8081 ; then
if ! curl -s "http://localhost:8081/status" | grep -q "packager- 
status:running" ; then
echo "Port 8081 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 "Can't start packager 
automatically"
fi

Upvotes: 0

Tareq El-Masri
Tareq El-Masri

Reputation: 2573

I had issues with the build after Xcode update, what I did to fix it is switch the Build System to Legacy Build System

From File > Workspace Settings

enter image description here

Or by pressing on the hammer icon on the right of the status bar

Change the build system to Legacy Build System

enter image description here

Also make sure that you still have the bundle script in Build Phases

enter image description here

Tell me know if that works with you

Upvotes: 1

Related Questions