How to rename react-native entry file (index.ios.js)

前端 未结 2 790
夕颜
夕颜 2020-12-16 15:04

When I init a react-native project, index.ios.js is created as project entry file.

Can I change this file\'s name and if so, how?

2条回答
  •  情歌与酒
    2020-12-16 15:33

    Suppose you've moved your index.ios.js into a folder called dist. You need to do two things

    1. For your development environment: Update jsBundleURLForBundleRoot in AppDelegate.m to match your updated path.

    2. For your release bundle: Open your Xcode project. You'll need to update the Bundle React Native code and images task under Build Phases for your project. Update the shell script in this section to look like below:

      export NODE_BINARY=node ../node_modules/react-native/packager/react-native-xcode.sh dist/index.ios.js

      react-native-xcode.sh accepts the ENTRY_FILE as an optional first argument, defaulting to index.ios.js if none is found.

      Updated Build Phases Example

      Reference - react-native/scripts/react-native-xcode.sh

提交回复
热议问题