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?
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?
Suppose you've moved your index.ios.js
into a folder called dist
. You need to do two things
For your development environment: Update jsBundleURLForBundleRoot
in AppDelegate.m
to match your updated path.
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.
When you start a react-native app you'll see this message output by the React Packager:
and then:
By this point, the packager has compiled your JS files and is serving them with the
.js
extension renamed to.bundle
. For example, yourindex.io.js
file is compiled and served from:If you added another file
foo.js
in the same directory asindex.ios.js
, the packager would serve it from:You can confirm this by opening that url in your browser.
Now to answer your question, your project has an
iOS/AppDelegate.m
file with the following line:... as you can see, it loads the
index.ios.bundle
. You can change the path/filename there to whatever you want, but it's probably best to stick with the recommended approach of naming your entry fileindex.io.js