Open rnnyrk opened 5 years ago
I've found a solution in this Stack Overflow post. Following these steps you can create a main.jsbundle
and assets
folder and add it to your project.
react-native bundle --dev false --platform ios --entry-file index.js --bundle-output ios/main.jsbundle --assets-dest ./ios
main.jsbundle
and assets
directory to Xcode by dragging them in your project.Although this feels like a temporary solution.. I've got two main.jsbundle
files right now. Can I delete the one in my project folder? And the assets
folder includes some node modules do I have this command every time I add new modules and manually drag the assets in my project root?
Also when I build it via CI/CD (Bitrise) there is no main.jsbundle
created in the root since it is ignored by default in .gitignore
. So my TestFlight builds are still failing. How to handle this?
What exactly is happening here?
Resolved the issue. Seemed like my project was missing a shell script to automatically build the bundle and assets under "Build Phases > Bundle React Native code and images". Also Xcode was crashing when I opened this section.
I opened the file /ios/Project.xcodeproj/project.pbxproj
, searched for this part:
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
};
and added the shell script, so I ended up with:
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
};
Hopefully this prevents others to spend 2 days on this ;)
there is already this line in my file, however, when running use of my device or error continues. He is only working on the emulator
got this issue coming from RN0.60.5 to RN0.61.1, I experience so many issue upgrading to the latest version. Then the only issue I'm facing now is this one. The Metro bundle was not initiating and I need to manually run "react-native start" which is not good. I hope someone can find solution for this issue.
same problem to update 0.59.9 to 0.61.1
same here
+1
same problem here
Same issue for me.
2019-10-07 17:56:49.686 [fatal][tid:main] No bundle URL present.
Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2019-10-07 17:56:49.692042+0200 SesameApp[3795:761740] No bundle URL present.
Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2019-10-07 17:56:49.693555+0200 SesameApp[3795:761740] *** Terminating app due to uncaught exception 'RCTFatalException: No bundle URL present.
Make sure you're running a packager server or have included a .jsbundle file in your application bundle.', reason: 'No bundle URL present.
Make sure you're running a packager server or have included a .jsbundle file in your application bundle.'
*** First throw call stack:
(0x1ee34298c 0x1ed51b9f8 0x1000dc79c 0x1000f3c6c 0x1edd80a38 0x1edd817d4 0x1edd2f008 0x1ee2d432c 0x1ee2cf264 0x1ee2ce7c0 0x1f04cf79c 0x21ad99c38 0x1000c1f98 0x1edd928e0)
libc++abi.dylib: terminating with uncaught exception of type NSException
Resolved the issue. Seemed like my project was missing a shell script to automatically build the bundle and assets under "Build Phases > Bundle React Native code and images". Also Xcode was crashing when I opened this section.
I opened the file
/ios/Project.xcodeproj/project.pbxproj
, searched for this part:/* Begin PBXShellScriptBuildPhase section */ 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); name = "Bundle React Native code and images"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; };
and added the shell script, so I ended up with:
/* Begin PBXShellScriptBuildPhase section */ 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); name = "Bundle React Native code and images"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; };
Hopefully this prevents others to spend 2 days on this ;)
I downgraded to Xcode 10.3 and applied that, it's working now thank you.
It happened to me as well when I upgraded react-native from '0.59.9' to '0.61.2'. For anyone still experiencing this, after the upgrade please check if there is a build phase in xcode called Start packager. If not click the + sign and choose 'new run script phase'. You will see a new phase called 'Run script' added to the bottom of the build phases. Add this shell script code
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 "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 "Can't start packager automatically" fi fi
Change its name to 'Start packager' and move it to the between 'Check Pods Manifest.lock' and 'Compile sources'. I hope it helps.
I'm having the same issue. I open my bundler manually and even though it seems like the app can't reach it even though NSAppTraspotSecurity is correct. Anyone has found solutions for this?
Same for me, @ergunyasar your solution doesn't work. It gives me an error during build.
I re-opened this issue since a lot of people seem to have encounter the same error with assumedly another solution.
The script that I have found in another issue and that is working for me is the following:
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 "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 "Can't start packager automatically"
fi
fi
All the steps are pretty much the same that @ergunyasar wrote: the only thing that changes is the script code above.
RN 0.61.3
Yes! Thx a lot @davidmarinangeli and @ergunyasar adding the script (David edition) worked for me (after trying a bunch of the other solutions out there).
I was trying to go through the official "Getting Started" and I faced the same issue following all the steps. The expo "Getting started" steps are working though.
First, when I keep the default port, it will crash with a port in use error: (Note that there is nothing listening on that port. lsof -t -i:8081
return nothing
npx react-native run-ios
Port 8081 already in use, packager is either not running or not running correctly
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Start\ Packager /AwesomeTSProject2/ios/build/AwesomeTSProject2/Build/Intermediates.noindex/AwesomeTSProject2.build/Debug-iphonesimulator/AwesomeTSProject2.build/Script-FD10A7F022414F080027D42C.sh
(1 failure)
Then if I change the port
npx react-native run-ios --port 9092
I got the same error as describe here
no bundle url present
@rnnyrk solution works fine as long as I keep specifying a custom port.
When I use the default, I got the first error even after the fix.
I use @davidbiedenbach solution and i had to combinate it with this solution: https://stackoverflow.com/a/54230598/2360269
@eggybot Are you using iterm2 or integrated terminal in VS Code? If so, run react-native run-ios
command from a default terminal. For me, it solved the issue. I couldn't believe how I spent a few hours on this.
@rnnyrk @arthurstockler @eggybot @ivanguimam @ivannovazzi
this video saved me , I have tried
https://www.youtube.com/watch?v=eCs2GsWNkoo
It happened to me as well when I upgraded react-native from '0.59.9' to '0.61.2'. For anyone still experiencing this, after the upgrade please check if there is a build phase in xcode called Start packager. If not click the + sign and choose 'new run script phase'. You will see a new phase called 'Run script' added to the bottom of the build phases. Add this shell script code
where is the + sign? @ergunyasar
All,
I am on the latest version of react-native cli and react-native, react-native-cli: 2.0.1 react-native: 0.61.5 I am trying to initialise a brand new project and run it in the iOS simulator and have run into this issue consistently no matter what I try , i. e create a new project, remove the build directory in iOS and try running it.
However the video suggestion did work but it had a lot of unnecessary side effects like losing hot reloading etc.
Is there a fix available for this issue ? if downgrading is an option I am happy to downgrade the cli and react-native versions.
Thanks in advance for any help.
I am upgrading from react native 0.59.10 to 0.60.6 and i am facing this issue, i have tried all the solutions/suggestions posted in this thread. But no luck 😞 If anyone has found a solution please help.
All,
I am on the latest version of react-native cli and react-native, react-native-cli: 2.0.1 react-native: 0.61.5 I am trying to initialise a brand new project and run it in the iOS simulator and have run into this issue consistently no matter what I try , i. e create a new project, remove the build directory in iOS and try running it.
However the video suggestion did work but it had a lot of unnecessary side effects like losing hot reloading etc.
Is there a fix available for this issue ? if downgrading is an option I am happy to downgrade the cli and react-native versions.
Thanks in advance for any help.
Okay, Here is what happened now. I created a new project and initialised it as per usual and it worked. I used npx react-native run-ios
and it seems to have worked without any issues.. Previously I was using react-native run-ios. Which I reckon may have used a older version of react-native hanging around somewhere in my refs.
I am upgrading from react native 0.59.10 to 0.60.6 and i am facing this issue, i have tried all the solutions/suggestions posted in this thread. But no luck If anyone has found a solution please help.
I upgrade xcode to the lasted version, it worked
If none of these have worked, my issue was with the packager (responsible for the bundle) build phase disappearing.
Check out the solution for the packager problem here: https://github.com/facebook/react-native/issues/25585
Also, make sure react-native-cli doesn't call an old globally-installed version and instead the one installed in your project by react-native. Run npm uninstall -g react-native-cli
and use yarn commands to use react-native-cli.
Hi there, I got the same error starting a new project at 0.61.5. I deleted the ios/build folder and re-run the react-native run-ios.
It worked for me.
Thanks
What worked for me is a combination of the solutions that have been posted.
react-native start
(to manually launch the bundler)react-native run-ios
This worked for me.
I encountered this error during a 0.60+ upgrade, even when I can verify that the metro bundler is running on port 8081. It seems that react-native is failing to detect the existence of a running server on that port -- or perhaps its looking for a different port altogether? using the --port
flag has no benefit. deleting ios/build
and reinstalling dependencies has no effect
I had a similar issue in which the package was indeed running as I started it manually yet the app was still complaining with the "No bundle URL present" error screen on react-native@0.61.5 I noticed in the logs of xcode that something was trying to access port 8083:
Task <>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x600002d86550 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=http://localhost:8083/status, NSErrorFailingURLKey=http://localhost:8083/status, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
So I (naively) tried running the packager on that same port, 8083, then reloaded the app in the simulator and it magically worked:
npx react-native start --port 8083
Hope this helps at least one poor(t) soul out there in the wild 🚀
I encountered this error during a 0.60+ upgrade, even when I can verify that the metro bundler is running on port 8081. It seems that react-native is failing to detect the existence of a running server on that port -- or perhaps its looking for a different port altogether? using the
--port
flag has no benefit. deletingios/build
and reinstalling dependencies has no effect
hi nick, have you found solution ?
same problem to update 0.59.9 to 0.61.1
same in 0.61.5.
I overcame this by creating a brand new react-native app with RN 0.61.5, then laboriously porting our existing app over. It wasn't pleasant, but it worked. Attempting to upgrade our existing app to 0.61.5 led us to encounter too many road-blocks (like this one)
I am still facing it, actually using main.jsbunlde file works fine but as pre-bundled file , I have to make bundle file each time to reflect changes so I don't think its a solution...
and using mace:8081 in appdegate.m giving me 401-authentication error.
Let me shed some light on the "No Bundle URL present" mystery.
Your React Native application knows where the bundler server is by a neat script called react-native-xcode.sh
which runs a few commands to determine your machine's IP address and write it to the ip.txt
file that can be later read by your app (as it will be bundled in the app along with the other files).
What might happen here is that for some reason you don't run the script when building your apps.
For example: you work on two machines and have a "Run script only when installing" checkbox checked for "Bundle React Native code and images". In this case, you might install your app on the device using machine A and then, in the evening, try to run it with machine B. That won't work, because this script won't be re-triggered and hence, your application bundler IP address will keep pointing to the machine A. In order to solve this, you'll have to either remove the app from your phone and re-install again or uncheck the checkbox.
Hope this helps ✌️
For me, the reason is that I didn't rollback the code in AppDelegate.m after I build the release version below
`- (NSURL )sourceURLForBridge:(RCTBridge )bridge {
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; // return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
}
@end `
@rnnyrk @arthurstockler @eggybot @ivanguimam @ivannovazzi this video saved me , I have tried https://www.youtube.com/watch?v=eCs2GsWNkoo
save my day, thanks a lot!
https://powercoder23.wordpress.com/2017/10/29/solved-no-bundle-url-present/
this link save my life after 3 days I fixed this error
And sometime this error is due to your device and computer not being on the same network.
I resolved the problem putting my device and computer in the same network :)
I had this because the IP address I need to use is on en5 and react-native-xcode.sh only checks en0 and en1 before grepping ifconfig for the first inet address (which in my case was an IP address created by Parallels). It first happened to me on an older project that used to work fine, so didn't seem to be related to React Native itself but to my Mac setup.
I created a PR to check en0..en8 rather than just en0 and en1: https://github.com/facebook/react-native/pull/28764
What worked for me is a combination of the solutions that have been posted.
- Delete ios/build folder
- Run
react-native start
(to manually launch the bundler)- Open new tab and run
react-native run-ios
This worked for me.
This one worked for me. I didn't delete the ios/build folder. Instead I used a regular terminal and not iTerm2.
This error occurred to me because I was using NVM and I replaced de Node binary path in Build phases -> Bundle React Native code and images with "which node" path. Everything worked fine with the simulator but not while running on device or testflight build . To solve this I re-installed Node with the oficial package installer and returned Node binary path to its original value. Hope this helps.
Many people have this issue recently and asking about this “No bundle URL present” error and I just faced it myself.
I got this error when I updated my react-native version, different people got this issue for a different reason, some are not sure what they changed
Even still, I will randomly get this error for almost no reason (not running a proxy, not making any crazy project changes). To fix it I will just delete my node_module, then npm install and it works. But it is a little worrying that it happens so randomly.
The most common fix that worked for the majority of the people is
Open a terminal window
cd into YOUR_PROJECT/ios
Remove the build folder with rm -r build
Run react-native run-ios again
If still, it doesn’t work, I have collected some solutions that worked for different conditions
Let's start with some basic troubleshooting
While the simulator is running don’t close your bundler. Go to the path and run
npm install
then again
react-native run-ios
Clean up your code, Clean the project directory, Removing the node_modules and do npm install again
Restarting your Simulator and the packager Terminal might work
Close everything and build the app through Xcode might work
Remove the build folder YOUR_PROJECT/ios/build/ and run react-native run-ios may work
Upgrading your react-native using
react-native upgrade
More advance
Adding NSAllowsLocalNetworking to Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key> <true/>
<key>NSAllowsArbitraryLoadsInWebContent</key> <true/>
<key>NSAllowsLocalNetworking</key> <true/>
</dict>
Port is already in useThis also means the “Port already in use”. Terminating a process on port 8081 Run the following command in the terminal to find the id for the process that is listening on port 8081: $ sudo lsof -i :8081 Then run the following to terminate the process: $ kill -9 Missing Native code OR assets(images) There might be a chance where you could have accidentally deleted the native code or images, Manually re-adding the in the Build phase might solve the problem Proxy Settings If you are using proxies like Shadowsocks, Issue might be related to network settings and is very likely related to proxy settings. If a proxy is used, do not forget to set a bypass proxy for localhost and 127.0.0.1 addresses. OR Disable proxy everything should be fine.
https://powercoder23.wordpress.com/2017/10/29/solved-no-bundle-url-present/
These are some popular fixes used to solve the issue, hope it helps Sources: https://github.com/facebook/react-native/issues/12754 https://stackoverflow.com/questions/42610070/what-means-of-no-bundle-url-present-in-react-native
I'm experiencing the same issue. Upgraded from RN 61.2 to 62.2. No solution mentioned above helps.
Having the same issue here trying to build ios for production! No solution above helped.
React native version: 0.61.5
Xcode version: 11.4.1
Xcode version : 11.5
Same issue after manually upgrading from 0.61.5
to 0.62.2
. I tried all stuff above but none was fruitful. Creating own main.bundlejs
with react-native bundle
only makes static bundle, it doesn't connect with the server.
No issue arround ports, it really seems the iOS build can't create the main.bundlejs
automatically by executing node_modules/react-native/scripts/react-native-xcode.sh
, but the script is not returning errors.
I have no idea yet, trying to upgrade to 0.63.0-rc1
.
EDIT : upgrade to 0.63.0-rc1
didn't fix this issue. Have you guys some idea to know what's going on? I feel like this line "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
in project.pbxproj
is the root of this issue, but I'm not so sure.
After struggling for days with this issue on 2 separate apps (in both cases the issue occurred after upgrading React Native), I finally decided to recreate the iOS project folder following this solution. Note that you may need to reinstall some libraries after recreation the folder, but it's the fastest solution that I've found that actually works.
Xcode version : 11.5
RN version : 0.63.0-rc1
I found something, not sure if it's the root of the issue for you guys.
In AppDelegate.m
there is this snippet :
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
But it turns out DEBUG
is not set while it should be. So the app is looking for a jsbundle
which is not created since the command npx react-native run-ios
does not create it.
I have no idea why DEBUG
is not set to 1
, all Swift params have the -DDEBUG
... If anyone have an idea on this, it would be nice.
I finally found out my issue. I was missing env var in XCode project FB_SONARKIT_ENABLED=1
in Build Settings -> Preprocessor Macros -> Debug.
I've just updated my project from React Native
0.59.9
to0.60.5
withreact-native upgrade
and the update helper mentioned in the official blog post. Although my project is already a little "complex" because it's using some libraries etc. it seemed the update was successful.But unfortunately my app won't work with the
Test - Release
scheme anymore. On the debug scheme it works without any problems. The release also reaches the "Build succeeded" status, but as soon the app launches it's stuck because of the "No bundle URL present" error (see also my attached Xcode screenshot).I've tried everything I could find on the internet so far. Re-installing the NPM dependencies and Pods; removing the build folder, changing the
NSAppTransportSecurity
in theInfo.plist
, but it won't resolve the issue.. The deployed app via TestFlight breaks as well on startup.React Native version:
System: OS: macOS 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz Memory: 430.30 MB / 8.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 23, 26, 28, 29 Build Tools: 28.0.3, 29.0.0 System Images: android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.60.5 => 0.60.5 npmGlobalPackages: react-native-cli: 2.0.1
Steps To Reproduce
node_modules
,ios/Pods
,ios/build
andPodfile.lock
node_modules
and runpod install
Project.xcworkspace
Files / Code
Currently these are my
Info.plist
,Podfile
andpackage.json
:The
AppDelegate.m
should link to the correct bundle file right? This code is in there: