【问题标题】:can i code an Android App then build an IOS app with react-native我可以编写一个 Android 应用程序然后用 react-native 构建一个 IOS 应用程序吗
【发布时间】:2021-09-09 17:18:11
【问题描述】:

我开始学习 react-native,但在设置环境时遇到了一些问题,对此我有一些疑问:

第一次写:

npx react-native init new_app

我得到一个错误,那个错误说 try:

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 准备好环境,然后开始在您的应用上运行?

【问题讨论】:

    标签: javascript android ios react-native cocoapods


    【解决方案1】:

    要回答您的第一个问题,不幸的是,如果您想为 IOS 构建应用程序,则需要 Xcode。

    要回答您的其他问题,完全可以为 android 而不是 IOS 构建。他们的构建过程在很大程度上彼此独立运行。我将避免您在此处查看为 android 构建和开发的所有步骤,但文档应该为您提供所需的一切。 https://reactnative.dev/docs/running-on-device

    【讨论】:

    • 所以我可以先从 android 开始,当我完成 android 应用程序后,如果我想安装 XCode 并为 IOS 构建应用程序是 okeey,如果环境没有准备好,没有风险IOS类似上图的错误?
    • 当然,您必须通过配置来确保在为 IOS 构建时不会发生错误,但为 android 构建的行为不会成为这些问题的原因。
    猜你喜欢
    • 1970-01-01
    • 2020-05-17
    • 2017-12-13
    • 2021-08-07
    • 1970-01-01
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多