I’ve got a React Native project and everytime I run it (run, not run with build) XCode rebuilds not everything but a lot of stuff even when there’s been zero code changes, with the result that everytime I hit run in XCode I have to wait 4 minutes before it starts.
Similar quesetions have been asked before and I’ve checked stuff such as ensuring Incremental Building is turned on (I’m using Xcode 12.5, new build system).
Each time its run I can see that XCode is rebuilding every target, and as its a React Native app there are a very lot of targets.
Here’s an example of the build logging, most things take a fraction of a second to build, but some things take 10, 20, 30 seconds, and there hundreds of things being built. Is there anyway of stopping it doing all this each time it runs?
2
Answers
You didn’t give a lot to go on here – specifically on how you’re trying to run it from Xcode. But if you’re trying to run it from inside Xcode, make sure you’re choosing "Run" (⌘R) and not "Build" (⌘B) every time. You would want to "Build" if you added new pods or otherwise changed files/assets in Xcode, but if you just want it to run with the code/assets from the previous build, you can choose "Run". (Note that "Run" will still compile your react native and give you live reloading, it just doesn’t rebuild all of the swift packages and assets each time.)
There is actually an option in Xcode to run without building the code first. Select the "Run Without Building" option under Product > Perform Action. The hotkey for this is ctrl + cmd + R.
How to prevent Xcode from rebuilding project every time