Michael C
Michael C

Reputation: 153

React-Native iOS app - running on device...error message: No bundle URL present

I built an app that runs well on iOS Simulator. When I try to build it on an iOS device however, the build and installation succeeds but upon open, I get this message:

No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.

RCTFatal

__28-[RCTCxxBridge handleError:]_block_invoke

I've now tried on three devices so device isn't issue. So far I've: 1) deleted iOS build folder and rebuilt 2) npm installed 3) cleaned xCode data 4) Restarted every process several times

One thing I've noticed is that the React Packager doesn't bundle index.js at the end of the build like it does when I run Simulator. This may be the core of the problem but I'm not sure how to approach fixing it.

I've also read that using React-Native-Router-Flux (which I do) may have some impact on this process, but also not sure what relevant fix would be.

Thanks!

Upvotes: 1

Views: 9609

Answers (3)

jsina
jsina

Reputation: 4839

I got it resolved by including the below code in Info.plist file which I had removed from the production build.

<key>NSExceptionDomains</key>
    <dict>
  <key>localhost</key>
  <dict>
    <key>NSExceptionAllowsInsecureHTTPLoads</key>
    <true/>
  </dict>
</dict>

Upvotes: 2

Kartik Shah
Kartik Shah

Reputation: 916

Comment this line in Appdelegate.m

jsCodeLocation = [[RCTBundleURLProvider sharedSettings]jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

Use this line

 jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 

Then run a command for making a jsbundle :-

 react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

Hope it will helps you.!

Upvotes: -1

Aaron
Aaron

Reputation: 409

See if one of the solutions here works. You may have deleted the build folder and rebuilt, but these answers seem to suggest that killing all React-Native sessions before deleting and rebuilding might work.

What means of no bundle URL present in react-native?

https://github.com/facebook/react-native/issues/12754

https://www.google.com/search?client=safari&rls=en&q=No+bundle+URL+present.&ie=UTF-8&oe=UTF-8

It helps to include references to StackOverflow articles/issue threads you've already tried and didn't work.

Upvotes: 0

Related Questions