前兩天,當(dāng)我執(zhí)行npm run ios
俺泣,來了一段下面這個(gè)錯(cuò)誤
=== BUILD TARGET mobileTests OF PROJECT mobile WITH CONFIGURATION Release ===
Check dependencies
** BUILD SUCCEEDED **
Installing build/Build/Products/Debug-iphonesimulator/mobile.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
/Users/astiefel/workspace/bosspayments/mobile/node_modules/promise/lib/done.js:10
throw err;
^
Error: Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/mobile.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
我的環(huán)境
system: macOs Big Sur
react: 16.13.1,
react-native: 0.63.2,
xcode: 12.3 (12C33)
React Native CLI 是 react-native的命令行工具類疗认,像react-native run-ios就是來自于這個(gè)cli,使得react-native的可以方便的交互伏钠。當(dāng)你一直用一個(gè)舊版本cli侮邀,新的bug修復(fù)版本又沒有得到及時(shí)更新,就會(huì)遇到這個(gè)問題贝润。
解決方案绊茧,幾種情況:
?? 如果你的項(xiàng)目中有(yarn.lock 或 package-lock.json),打開它打掘,然后刪除所有@react-native-community/cli 開頭的包华畏,再次執(zhí)行 yarn install / npm install。
?? 如果沒有yarn.lock 或 package-lock.json) – 刪除 node_modules 再次 執(zhí)行 yarn install / npm install
?? 執(zhí)行 yarn list --pattern @react-native-community/cli
或 npm list @react-native-community/cli
驗(yàn)證是否得到最新版
?? 如果以上還是不起作用尊蚁,進(jìn)這找到最新版本@react-native-community/cli,手動(dòng)把react-native-community/cli
版本調(diào)成最新版本亡笑。
以上是比較有效的解決方案,由于xcode過一段時(shí)間就會(huì)去更新版本横朋。react-native會(huì)隨時(shí)修復(fù)這些兼容仑乌,所以遇到問題考慮更新cli
以下是不推薦的方法
- ?? react-native upgrade。太過復(fù)雜
- ?? 修改xcode的build system為L(zhǎng)egacy build system,或修改Build/為build/Build/*, 但是xcode明確的提示這個(gè)模式將來會(huì)deprecated晰甚。不是首選衙传。
對(duì)于這個(gè)錯(cuò)誤眾說紛紜,當(dāng)然每個(gè)人的系統(tǒng)環(huán)境不一樣厕九,可能會(huì)有不同的解決方案蓖捶。
?? 以上是官方的方式,僅供參考扁远。