question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NSInternalInconsistencyException: bundleURL must be non-nil when not implementing loadSourceForBridge

See original GitHub issue

I am using react-native 0.31.0-rc.1. I am observing the error in iOS on Mac.

I recently update react-native on my app to the latest and started to get this error (detailed error below). This only happens when I try to run the app on the phone by using Option 2 which is to load using a static bundle. I have tried:

  • Clean and rebuild in Xcode
  • Reset cache and run react packager
  • Uninstall the app on the phone
  • Coming from Windows background, I have also tried to reboot my machine

Error in Xcode

2016-08-04 09:34:37.611 GalarmApp[367:165469] *** Assertion failure in
-[RCTBatchedBridge loadSource:](), /Users/abc/Projects/GalarmApp/node_modules/react-native/React/Base/RCTBatchedBridge.m:180 2016-08-04 09:34:37.613 GalarmApp[367:165469] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleURL must be non-nil when not implementing loadSourceForBridge'
*** First throw call stack: (0x182b32db0 0x182197f80 0x182b32c80 0x1834b81c0 0x1000af788 0x1000adefc 0x1000adca4 0x1000e73d8 0x1000e7368 0x1000e6700 0x1000e643c 0x10005a254 0x10003cebc 0x10003c214 0x10003966c 0x100039b18 0x187d069c0 0x187f36184 0x187f3a5f0 0x187f37764 0x1844d37ac 0x1844d3618 0x1844d39c8 0x182ae909c 0x182ae8b30 0x182ae6830 0x182a10c50 0x187cff94c 0x187cfa088 0x10003bee0 0x1825ae8b8) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

I can see that this problem is printed here in the code but I am a beginner at best in native iOS development and don’t know how to fix this problem.

Please help me in fixing this problem. Thanks!

Code in AppDelegate.swift file

/**
 * Loading JavaScript code - uncomment the one you want.
 *
 * OPTION 1
 * Load from development server. Start the server from the repository root:
 *
 * $ npm start
 *
 * To run on device, change `localhost` to the IP address of your computer
 * (you can get this by typing `ifconfig` into the terminal and selecting the
 * `inet` value under `en0:`) and make sure your computer and iOS device are
 * on the same Wi-Fi network.
 */
// let jsCodeLocation = NSURL(string: "http://localhost:8081/index.ios.bundle?platform=ios&dev=true")


 /**
 * OPTION 2
 * Load from pre-bundled file on disk. The static bundle is automatically
 * generated by "Bundle React Native code and images" build step.
 */
let jsCodeLocation = NSBundle.mainBundle().URLForResource("main", withExtension: "jsbundle")

print (jsCodeLocation)

let rootView = RCTRootView(bundleURL:jsCodeLocation, moduleName: "galarm", initialProperties: nil, launchOptions:launchOptions)

As you can see, I have commented out Option 1 and uncommented out 'Option 2. The jsCodeLocation is printed as nil. I have run the same app this way on the device like 100 times when I was usingreact-native 0.24.0`. I have not made any changes to the code and I started to see this error after the upgrade.

I have also asked this question on stackoverflow but since I was not getting any responses, I thought I will raise an issue here as well

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
kyle-ssgcommented, Jan 11, 2017

I got this when migrating a native project over to react native: check that the following is in your info.plist (right click it and edit as source).

<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSExceptionDomains</key>
		<dict>
			<key>localhost</key>
			<dict>
				<key>NSIncludesSubdomains</key>
				<true/>
				<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
				<true/>
			</dict>
		</dict>
	</dict>

Note, i did not have to “Go back to old school” - i’m still using jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

4reactions
varungupta85commented, Aug 6, 2016

Please refer to the accepted answer for this question on stackoverflow. Looks like the IP detection for the ios bundle has been automated due to which the two options were removed and there is just one now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bundleURL must be non-nil when not implementing ...
NSInternalInconsistencyException : bundleURL must be non-nil when not implementing loadSourceForBridge · You should add the bundle URL in AppDelegate. · @Sriraman ...
Read more >
bundleURL must be non-nil when not implementing ...
Coding example for the question NSInternalInconsistencyException: bundleURL must be non-nil when not implementing loadSourceForBridge.
Read more >
RN第一坑–
... to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleURL must be non-nil when not implementing loadSourceForBridge'.
Read more >
iOS开发,刚接手React-native,遇到的问题,求教!-CSDN社区
... app due to uncaught exception 'NSInternalInconsistencyException', reason: 'bundleURL must be non-nil when not implementing loadSourceForBridge'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found