Search code examples
react-nativecode-push

Unable to run CodePush offline bundle when connected to chrome debugger. Using React Native with iOS


I'm using CodePush with React Native and iOS. When hooked up to the chrome debugger with CodePush, while using the CodePush offline bundle, I get this error:

Uncaught NetworkError: 
Failed to execute 'importScripts' on 'WorkerGlobalScope': 
The script at 'file:///Users/naderdabit1/Library/Developer/CoreSimulator/Devices/115F136F-…ation/B0ECCD9D-8274-4308-A9C7-BAA2746FDF02/StudentStatus.app/main.jsbundle' 
failed to load.

enter image description here

The error goes away when I switch to the local bundle or disable the chrome debugger.

Any ideas? thanks.


Solution

  • Can you confirm that you don't see this same error when setting your JS bundle location to [NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"] in your AppDelegate.m file and then enabling Chrome Debugging? It was my understanding that you could only enable Chrome debugging when your app is loading the JS bundle from the packager, and since using [CodePush bundleURL] is loading your JS bundle from disk (either the bundle contained in your binary or the latest CodePush update), it naturally wouldn't support the Chrome debugging scenario.

    We've done work to make sure that the CodePush plugin will work in concert with the packager, so that devs can use their natural debugging workflow (e.g. livereload, Chrome support) without needing to change anything just to support testing/co-existing with CodePush. Our docs currently recommend using the following solution for iOS, and I'd love to know if there is a scenario that we're missing and can improve:

    NSURL *jsCodeLocation;
    
    #ifdef DEBUG
        jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
    #else
        jsCodeLocation = [CodePush bundleURL];
    #endif