問題
在我搭建好rn環(huán)境運(yùn)行react-native run-ios出現(xiàn)下面錯(cuò)誤,導(dǎo)致程序始終跑不起來。
Command failed: /usr/***/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/imoocApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
原因
在查閱了網(wǎng)上大量資料發(fā)現(xiàn),這個(gè)原因很可能是npm版本導(dǎo)致文件下載不全或者是rn版本導(dǎo)致。
解決方法
1.使用Yarn替代npm,運(yùn)行一下命令安裝Yarn,
//下載Yarn
npm install -g yarn react-native-cli
//設(shè)置國內(nèi)鏡像
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
最后重新運(yùn)行install,再run就可以解決如上問題
yarn install
react-native upgrade
react-native run-ios
2.除了上述方法還可以使用修改rn版本來解決
npm install --save react-native@0.18 //項(xiàng)目降級或升級到指定版本,記得react-native upgrade更新一下