main.jsbundle file showing in my iOS project but still throwing “No bundle url present”

前端 未结 2 1984
臣服心动
臣服心动 2021-02-10 22:38

I am creating a new React Native app but facing errors like "No bundle URL present" while running it on iOS Simulator.

Command to Run App on iOS:



        
2条回答
  •  无人及你
    2021-02-10 22:46

    I would like to add the solution that I found as I had initially buried but not solved the error using the build:ios method. This answer is for others also struggling and might be a solution:

    My main.bundle.js wasn't present because the node_modules/react-native/scripts/react-native-xcode.sh failed to bundle because the relative import paths differ in debug vs releases in RN.

    I was attempting to import SVG files using babel-inline-import + react-native-svg. Because react-native runs the debug mode from your command line the root will match in the files importing the svg's, but because when React Native builds in release mode (on the CI or when you do Xcode->Product->Archive) it runs the .sh script to make the bundle with the iOS folder as root. So now the patbs are broken.

    If you use the build:iOS trick you skip that error but the app crashes immediately, because it's still missing the assets. The tricky part was finding the relatively simple error in the logs. Spent a three days on this as well.

提交回复
热议问题