最近闲来没事,又开始继续我的RN项目,由于有一段时间没有做了,想重新建一个项目,按照之前的顺序。(前提环境已经装好)
环境 mac 版本10.12.5
1.默认情况下安装react-native init MyTestApp
2.cd MyApplication
3.npm start
4.react-native run-ios
以上是我默认的步骤进行工程的创建,但是在运行的总是失败。
错误信息
“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打开工程后发现 在react目录下缺少文件依赖(.rncache这个目录下的文件)。网上说有可能是被墙的原因。所以这个版本(0.48.3)可能会出问题。我觉的应该试试0.44.3 ,修改package.json后的也没有直接解决 。
于是我在初始化创建的时候进行一个0.48.3版本,直接用默认的选项。
命令:
react-native init MyApplication --version 0.44.3
完成后 我先运行了npm start ,启动服务后
react-native run-ios
出现了久违的画面。
ps.在默认初始化的时候我将缺少的文件在网上找了一下,找到了一个下载地址,放进去之后,发现还是缺少其他的依赖,这里就不贴出来了。