最近閑來沒事,又開始繼續(xù)我的RN項目,由于有一段時間沒有做了,想重新建一個項目淘捡,按照之前的順序。(前提環(huán)境已經(jīng)裝好)
環(huán)境 mac 版本10.12.5
1.默認情況下安裝react-native init MyTestApp
2.cd MyApplication
3.npm start
4.react-native run-ios
以上是我默認的步驟進行工程的創(chuàng)建池摧,但是在運行的總是失敗焦除。
錯誤信息
“Unpacking /Users/XXXX/.rncache/double-conversion-1.1.5.tar.gz...”
Unpacking /Users/XXXX/.rncache/boost_1_63_0.tar.gz...
boost_1_63_0/boost/thread/pthread/shared_mutex_assert.hpp: (Empty error message)
tar: Error exit delayed from previous errors.
Unpacking '/Users/XXXX/.rncache/boost_1_63_0.tar.gz' failed.? Debug info:
-rw-r--r--? 1 XXXX? staff? 1078857? 9 15 21:19 /Users/XXXX/.rncache/boost_1_63_0.tar.gz
ed3babdf02ad82e586b5840d166e2c4fefee9a71? /Users/XXXX/.rncache/boost_1_63_0.tar.gz
Command /bin/sh failed with exit code 1
** BUILD FAILED **
The following commands produced analyzer issues:
Analyze /Users/XXXX/Desktop/code/RN/RN_gitOSC/RNProject/RN_Practice/12view/MyTestApp/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c
Analyze /Users/XXXX/Desktop/code/RN/RN_gitOSC/RNProject/RN_Practice/12view/MyTestApp/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.c
(2 commands with analyzer issues)
The following build commands failed:
PhaseScriptExecution Install\ Third\ Party /Users/XXXX/Desktop/code/RN/RN_gitOSC/RNProject/RN_Practice/12view/MyTestApp/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)
Installing build/Build/Products/Debug-iphonesimulator/MyTestApp.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/MyTestApp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist“
然后查詢資料:最常見的說法是修改package.json :"
dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "0.48.3"
},
修改為:
dependencies": {
"react": "16.0.0-alpha.6",
"react-native": "0.44.3"
},
然后刪除這個目錄下的node_modules 這個文件夾 然后重新 node install.
相當于重新安裝了react ,react-native 的版本作彤。但是運行后還是報錯膘魄。最后我用
xcode打開工程后發(fā)現(xiàn) 在react目錄下缺少文件依賴(.rncache這個目錄下的文件)。網(wǎng)上說有可能是被墻的原因竭讳。所以這個版本(0.48.3)可能會出問題创葡。我覺的應該試試0.44.3 ,修改package.json后的也沒有直接解決 绢慢。
于是我在初始化創(chuàng)建的時候進行一個0.48.3版本灿渴,直接用默認的選項。
命令:
react-native init MyApplication --version 0.44.3
完成后 我先運行了npm start 胰舆,啟動服務后
react-native run-ios
出現(xiàn)了久違的畫面骚露。
ps.在默認初始化的時候我將缺少的文件在網(wǎng)上找了一下,找到了一個下載地址缚窿,放進去之后棘幸,發(fā)現(xiàn)還是缺少其他的依賴,這里就不貼出來了滨攻。