我可以编写一个 Android 应用程序然后使用 react-native 构建一个 IOS 应用程序吗
can i code an Android App then build an IOS app with react-native
我开始学习 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 然后为 [=30= 构建相同的 android 代码] ?或者环境是否应该为 IOS 和 Android 做好准备,然后开始开发您的应用程序?
要回答你的第一个问题,如果你想为 IOS 构建你的应用程序,不幸的是 Xcode 是必需的。
为了回答您的其他问题,完全有可能为 android 而不是 IOS 构建。他们的构建过程 运行 基本上彼此独立。我将在此处免除您为 android 构建和开发的所有步骤,但文档应提供您所需的一切。 https://reactnative.dev/docs/running-on-device
我开始学习 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 然后为 [=30= 构建相同的 android 代码] ?或者环境是否应该为 IOS 和 Android 做好准备,然后开始开发您的应用程序?
要回答你的第一个问题,如果你想为 IOS 构建你的应用程序,不幸的是 Xcode 是必需的。
为了回答您的其他问题,完全有可能为 android 而不是 IOS 构建。他们的构建过程 运行 基本上彼此独立。我将在此处免除您为 android 构建和开发的所有步骤,但文档应提供您所需的一切。 https://reactnative.dev/docs/running-on-device