我开始学习 react-native 并且在设置环境时遇到了一些问题,我对此有一些疑问:
首先当我写:
npx react-native init new_app
我收到一个错误,该错误说尝试:
cd ./new_app/ios && pod install
然后我收到以下错误:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/macbookpro/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/macbookpro/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/macbookpro/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details
我知道我需要安装 Xcode,但由于某些原因我现在不想安装,那么我可以做些什么来让它在没有安装 Xcode 的情况下工作?
第二个问题,如何首先为 Android 初始化一个 react-native 应用程序?如果有办法做到这一点,当我想构建 IOS 应用程序时,我会遇到一些麻烦还是只需要 Xcode 然后为 IOS 构建相同的 android 代码?还是应该为 IOS 和 Android 准备好环境然后开始处理您的应用程序?
要回答您的第一个问题,不幸的是,如果您想为 IOS 构建应用程序,则需要 Xcode。
要回答您的另一个问题,完全可以为 android 而不是 IOS 构建。他们的构建过程在很大程度上相互独立。在这里,我将省去您为 android 构建和开发的所有步骤,但文档应该为您提供所需的一切。https://reactnative.dev/docs/running-on-device
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句