简体   繁体   中英

React-Native Static images don't show up in app on offline bundling

I did the following

  1. Commented

    jsCodeLocation = [NSURL URLWithString:@"localhost:8081/index.ios.bundle?platform=ios&dev=true"];

  2. Uncommented

    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

Then ran the following command from the root where index.ios.js is

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

Then from XCode I added main.jsbundle to the project ( Project > RightClick > Add files ...) but I am not sure where to put the assets folder that is created as a result of running the command, I tried adding assets folder to the project by the same method but static images still don't show up in the compiled binary. Where do I put the assets folder?

Instead of running bundle command and generating bundles and assets there is a better way around.

Follow instructions in Manual Upgrades section here https://facebook.github.io/react-native/docs/upgrading.html#from-0-13-to-0-14

Change Scheme to Release

Choose Option 2 in Appdelegate.m by uncommenting

That's it, now you can run your app on a physical device without the development server running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM