react-native iOS app not showing static assets (images) after deploying

前端 未结 5 1551
-上瘾入骨i
-上瘾入骨i 2020-12-01 12:58

I have all my static images in a folder called \"images\" in the root of my project. However, after I run the following command to bundle my app, the app works but no image

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 13:11

    The asset destination and the main.jsbundle have to be in the same folder. Try:

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

    The bundler will create an assets folder in there anyway.

    UPDATE including information from the discussions below:

    The react-native-xcode.sh script that is executed in a XCode build step copies the main.jsbundle and the assets folder created by the bundler into the app package. If you want to deploy the package manually you need to make sure, that those files are copied. The easiest way is to include the main.jsbundle directly into the project and create a folder link to the assets folder. Verify that both are showing up in 'Build Phases' -> 'Copy Bundle Resources'.

提交回复
热议问题