What is the meaning of 'No bundle URL present' in react-native?

前端 未结 30 2127
庸人自扰
庸人自扰 2020-11-30 17:22

When I run a react-native project, I get a error no bundle URL present , but I don\'t know what mistakes I do, I was very confused.

相关标签:
30条回答
  • 2020-11-30 17:33

    As instructed in the error message:

    Agreeing to the Xcode/iOS license requires admin privileges, please run "sudo xcodebuild -license" and then retry this command.

    Running the following command worked:

    sudo xcodebuild -license
    
    0 讨论(0)
  • 2020-11-30 17:33

    I had this issue happen for me as well...the issue was the packer wasn't running it seemed probably because my default shell was zsh. react-native tires to open a new terminal window and run .../node_modules/react-native/packager/launchPackager.command but this didn't run. Manually running that (and keeping it running) fixed this for me.

    0 讨论(0)
  • 2020-11-30 17:34

    I'm working with RN 0.49.5. I've tried lots of methods, but no one works. Finally i worked this out. It's simple and easy.

    Main idea is to change the localhost to 127.0.0.1, but it's not where the RN tells you. It's in RCTBundleURLProvider.m#- (BOOL)isPackagerRunning:(NSString *)host.

    Changes of code: oc - NSString *host = ipGuess ?: @"localhost"; + NSString *host = ipGuess ?: @"127.0.0.1"; This is ok for simulator. If it's device, just change the ip address to your machine's.

    0 讨论(0)
  • 2020-11-30 17:36

    Just run in Terminal react-native start:

    cd your react native app directory/ react-native start 
    

    It will start up the packager, now don't close this terminal window, in another terminal window run your project. This is the only want that I found to get it working properly.

    0 讨论(0)
  • 2020-11-30 17:37

    Be sure that your ATS settings are correct in .plist file.

    You can find the file at /ios/{{project_name}}/Info.plist

    localhost must be defined as exception request target like this:

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

    *(dont forget to remove this on release version..)

    0 讨论(0)
  • 2020-11-30 17:40

    I had the same error and was able to run the app only through Xcode. react-native run-ios did not work. To resolve the issue you need to remove the build folder at YOUR_PROJECT/ios/build/. After this you should be able to run your app through react-native run-ios again. Hope this helps.

    0 讨论(0)
提交回复
热议问题