v0.14.2 Static Image Asset Unable to Be Required when run on iOS from Xcode
It shows the following error when press run of Xcode on Simulators: uncaught error Error: UnableToResolveError: Unable to resolve module image!ic_search from ****/js/tab.home.js: Invalid directory /Users/node_modules/image!ic_search
I entered deep into the code, and found why it doesn't work.
in file react-native/private-cli/src/util/Config.js, it tries to find rn-cli.config.js from parent directories from react-native/local-cli, but file rn-cli.config.js is under directory react-native/packager/, so it cannot find it, and function getAssetRoots() will just return an empty array as configured inside default.config.js
Hey, since 0.14.2 dealing with image for iOS and android is unified. You have to specify relative path to image.
@Maxyss so how to do this?
I changed function getAssetRoots in react-native/local-cli/default.config.js as follows and it works now. But I know that this is not the right way.
getAssetRoots() {
return this.getProjectRoots();
},
Closing this as this is related to old assets system.