React native 生成main.jsbundle文件

2021-02-04  本文已影响0人  羽化行云

1.cd 到项目中有index.js或index.ios.js文件的目录下

cd reactnative

2.执行命令生成main.jsbundle

curl http://localhost:8081/index.ios.bundle -o main.jsbundle

3.将生成的main.jsbundle导入到工程中

4.将原来的

jsCodeLocation = [NSURL URLWithString:@"[http://localhost:8081/index.ios.bundle?platform=ios&dev=true](https://link.jianshu.com?t=http://localhost:8081/index.ios.bundle?platform=ios&dev=true)"];

替换成

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

示例:


image.png

5.就可以关掉server运行项目,脱离server,使用离线包

上一篇 下一篇

猜你喜欢

热点阅读