问题
在我搭建好rn环境运行react-native run-ios出现下面错误,导致程序始终跑不起来。
Command failed: /usr/***/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/imoocApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
原因
在查阅了网上大量资料发现,这个原因很可能是npm版本导致文件下载不全或者是rn版本导致。
解决方法
1.使用Yarn替代npm,运行一下命令安装Yarn,
//下载Yarn
npm install -g yarn react-native-cli
//设置国内镜像
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
然后重新把node_modules文件和ios/build删除,
rm -rf node_modules
rm -rf ios/build
最后重新运行install,再run就可以解决如上问题
yarn install
react-native upgrade
react-native run-ios
2.除了上述方法还可以使用修改rn版本来解决
npm install --save react-native@0.18 //项目降级或升级到指定版本,记得react-native upgrade更新一下