react-native開發:執行react-native run-ios報錯--Print: Entry, ":CFBundleIdentifier", Does Not Exist
阿新 • • 發佈:2019-02-06
情景
在新建立的ReactNative專案,執行命令:react-native init Hello
在專案資料夾下執行react-native run-ios,但是出現以下報錯:
Command /bin/sh failed with exit code 1
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Install\ Third\ Party /Users/shixinshan/Development/ReactNativeProjects/Mybaby/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190 EE32F1E6A43DE00A8543A.sh
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/Mybaby.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
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/Mybaby.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
原因分析
init命令預設會建立最新的版本,而目前最新的0.45版本需要下載boost庫編譯。此庫體積龐大,在國內即便翻牆也很難下載成功,導致很多人無法正常執行iOS專案,推薦暫時使用0.44.3的版本。
解決方法
建立專案暫時先使用react-native init MyApp –version 0.44.3,指定某個版本。
你可以使用–version引數(注意是兩個槓)建立指定版本的專案。例如react-native init MyApp –version 0.44.3。注意版本號必須精確到兩個小數點。