React Native 打包离线包

build package

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

change AppDelegate.m

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

copy main.jsbundle file to XCode project

notice: select Create folder references


problem

  • 项目如果设置了__DV__,打离线包的时候会出错
Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "BooleanLiteral"
  • 如果项目没有更改AppDelegate, 会报没有设置url之类的错误
No script URL provided. Make sure the packager is running or you have embedded a JS bundle in your application
  • 如果每次打的Release包都一样,Xcode选择Project > Clean,然后重新编译即可

你可能感兴趣的:(React Native 打包离线包)