你好 Stackoverflow 社区,
我对 React Native 完全陌生,并且已经在第一步中挣扎。我已经按照这个网站做了一切:https://reactnative.dev/docs/environment-setup
我已经安装了 node 和 watchman 我有 X 代码运行模拟 我已经安装了可可豆荚 我使用的编辑器是 VS Code,终端是 iTerm。
我按照文档中的描述创建了一个测试项目。
npx react-native init AwesomeProject
之后,我进入文件夹并在两个不同的终端中运行。
npx react-native start
npx react-native run-ios
当我在 Youtube 上看到人们这样做时,它总是有效,但我得到的是以下内容:
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'boost-for-react-native' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'YogaKit' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.4, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-PeerTalk' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-Glog' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'Flipper-DoubleConversion' from project 'Pods')
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the AwesomeProject editor. (in target 'AwesomeProject' from project 'AwesomeProject')
** BUILD FAILED **
The following build commands failed:
CompileC /Users/mw/Library/Developer/Xcode/DerivedData/AwesomeProject-hdnnulyuswlwrafjfjkeikstoeak/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Flipper.build/Objects-normal/x86_64/FlipperRSocketResponder.o /Users/mw/Desktop/AwesomeProject/ios/Pods/Flipper/xplat/Flipper/FlipperRSocketResponder.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
如果有人能帮我解决这个问题,我会非常高兴。我在 Stackoverflow 上看过其他一些帖子,但没有任何帮助。
非常感谢
更新
制作后我改变了
cd AwesomeProject/ios
a) Comment this line in Podfile
# use_flipper!()
b) pod install
随着跑步:
npx react-native run-ios
我收到此错误消息:
/bin/sh -c /Users/mw/Library/Developer/Xcode/DerivedData/AwesomeProject-hdnnulyuswlwrafjfjkeikstoeak/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-90F0FABA0342DD788075D851B9320B7C.sh
N/A: version "N/A -> N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
Command PhaseScriptExecution failed with a nonzero exit code
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the AwesomeProject editor. (in target 'AwesomeProject' from project 'AwesomeProject')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target 'boost-for-react-native' from project 'Pods')
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/mw/Library/Developer/Xcode/DerivedData/AwesomeProject-hdnnulyuswlwrafjfjkeikstoeak/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-90F0FABA0342DD788075D851B9320B7C.sh
(1 failure)
研究此错误消息时,我发现它可能与 NodeJS 有关,但已安装 Node。
答案 0 :(得分:0)
您需要一个额外的步骤:
1) npx react-native init AwesomeProject
2) cd AwesomeProject/ios
a) Comment this line in Podfile
# use_flipper!()
b) pod install
3) cd ..
npx react-native run-ios
答案 1 :(得分:0)
我在一个已经存在的项目中遇到了同样的问题。在这个项目中 Flipper 是必要的,所以在 Podfile 中注释掉它并没有解决问题。
这个带有依赖于 React Native 版本的指令的评论帮助我让项目在 iOS 模拟器中重新运行:https://github.com/facebook/react-native/issues/31179#issuecomment-830184757
答案 2 :(得分:0)
如果使用nvm
,尝试卸载nvm、node、npm、yarn,重新安装node