【问题标题】:react native fresh install build fails with Undefined symbol反应原生全新安装构建失败,带有未定义的符号
【发布时间】:2021-04-26 23:22:43
【问题描述】:

我在为 iOS 构建我的 RN 应用程序时遇到了问题。为了消除我自己的代码问题,我创建了一个新项目,但我遇到了同样的错误。我做了以下事情(我使用的是带有 M1 芯片的 Macbook Pro):

  • 使用npx react-native init TestProject 添加了全新安装
  • 成功完成pod update
  • 在 xcode 的项目根目录中添加了一个 .swift 文件来创建桥接头
  • 清理了构建文件夹
  • 试过npx react-native run-ios但失败了,所以我尝试从xcode运行,它也失败了

问题似乎与链接有关,以下是我收到的一些警告:

ld: warning: Could not find or use auto-linked library 'swiftFoundation' 
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftMetal'

然后在底部有一个错误说clang: error: linker command failed with exit code 1,列出了大约 23 个错误,都说Undefined symbol,然后是一堆 Swift 方法。

最初我认为这是我如何配置我的应用程序的问题,但由于全新安装也会发生同样的问题,我真的不知道从哪里开始。

我到处搜索并尝试了各种方法,例如旧版构建模式、更改各种构建设置,但都没有奏效。任何帮助将不胜感激。

我正在使用以下内容:

  • xcode 12.4
  • nodejs v16.0
  • npm v7.10.0
  • 反应 v17.0.1
  • react-native v0.64.0

【问题讨论】:

    标签: ios xcode react-native


    【解决方案1】:

    我最终通过使用 Rosetta2 来构建我的应用程序。这是我必须做的:

    • 我使用 Rosetta2 打开了终端
    • 删除了 node_modules 目录
    • 已删除 Pod 目录
    • 已删除 podfile.lock
    • 使用 Rosetta2 终端运行 npm installpod install

    一旦我这样做了,npx react-native run-ios 就会成功构建。

    我应该提一下,当我尝试使用 Flipper 构建时,构建失败了。当我从 Podfile 中删除 use_flipper!() 时,我的构建就成功了。

    我猜软件包仍然没有赶上与M1芯片兼容,所以目前Rosetta2是解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-06
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多