【问题标题】:Symbol(s) not found for architecture arm64 - XCode未找到架构 arm64 的符号 - XCode
【发布时间】:2022-10-20 18:34:51
【问题描述】:

我正在尝试在 Mac Intel 上构建我的 react 本机项目,但不断收到下一个错误:

Showing All Messages
Undefined symbol: _swift_stdlib_isStackAllocationSafe

架构 arm64 的未定义符号: “_swift_stdlib_isStackAllocationSafe”,引用自: 函数签名特化 <Arg1 = Owned To Guaranteed> 函数签名特化 <Arg[0] = [Closure Propagated :closure #1 (__C.SKProduct) -> Swift.Bool inclosure #2 (Swift.Set<__C .SKProduct>) -> () 在 PurchasesCoreSwift.IntroEligibilityCalculator.checkTrialOrIntroductoryPriceEligibility(with: Foundation.Data, productIdentifiers: Swift.Set<Swift.String>, completion: (Swift.Dictionary<Swift.String, __C.NSNumber>, Swift.可选<Swift.Error>) -> ()) -> (),参数类型:[Swift.Set<Swift.String>]> 的泛型特化 <__C.SKProduct> of Swift._NativeSet.filter((A) throws -> Swift.Bool) 抛出 -> Swift._NativeSet 在 libPurchasesCoreSwift.a(IntroEligibilityCalculator.o) ld:未找到架构 arm64 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

我已经尝试了几乎所有的答案:link

pod deintegrate 
pod install
pod repo update

我的反应原生版本:

"react-native": "0.64.2"

我的项目架构:

带有库的链接二进制文件

更新我还将 react 本机版本更新为 0.67.4,但仍然无法正常工作。

【问题讨论】:

标签: ios xcode react-native macos arm64


【解决方案1】:

对于 react-native 0.67+:经过大量研究,我找到了 Vegaro 的下一个解决方案:

SOLUTION LINK

第一步是将 React-native-purchases by Revenuecat 包升级到最新版本。

清洁你的豆荚: REFERENCE LINK TO PROPERLY CLEAN PODS

声明一个 pod 后安装过程: 在您的 Podfile 中添加以下内容:

 post_install do |installer|
    react_native_post_install(installer)
    fix_library_search_paths(installer)
  end
end

def fix_library_search_paths(installer)
  def fix_config(config)
    lib_search_paths = config.build_settings["LIBRARY_SEARCH_PATHS"]
    if lib_search_paths
      if lib_search_paths.include?("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)") || lib_search_paths.include?(""$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"")
        # $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME) causes problem with Xcode 12.5 + arm64 (Apple M1)
        # since the libraries there are only built for x86_64 and i386.
        lib_search_paths.delete("$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)")
        lib_search_paths.delete(""$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"")
        if !(lib_search_paths.include?("$(SDKROOT)/usr/lib/swift") || lib_search_paths.include?(""$(SDKROOT)/usr/lib/swift""))
          # however, $(SDKROOT)/usr/lib/swift is required, at least if user is not running CocoaPods 1.11
          lib_search_paths.insert(0, "$(SDKROOT)/usr/lib/swift")
        end
      end
    end
  end

  projects = installer.aggregate_targets
    .map{ |t| t.user_project }
    .uniq{ |p| p.path }
    .push(installer.pods_project)

  projects.each do |project|
    project.build_configurations.each do |config|
      fix_config(config)
    end
    project.native_targets.each do |target|
      target.build_configurations.each do |config|
        fix_config(config)
      end
    end
    project.save()
  end
end 

最后,手动更改项目中的库搜索路径(XCode)。 消除:

$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)

添加:

$(SDKROOT)/usr/lib/swift

清理您的项目并再次运行:“存档”构建。

【讨论】:

  • 'SOLUTION_LINK' 在 Expo -> RN 0.64 中为我工作。只有更改 pod 安装后脚本才能为我解决。谢谢,为此苦苦挣扎了几天。
【解决方案2】:

我有一个类似的问题M1 麦克这是我为解决此问题所做的:

  1. brew install watchman
    如果你没有节点 => brew install node
  2. sudo arch -x86_64 gem install ffi
  3. 将此代码添加到 ios 文件夹内的 pod 文件的末尾:
    post_install do |installer|
        installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
            config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
          end
        end
      end
    
    1. cd ios/ &amp;&amp; arch -x86_64 pod install

    2. 使用 Rosetta 运行 Xcode。

      您可以通过运行以下命令安装 Rosetta:softwareupdate --install-rosetta

    3. 排除架构 arm64。

    4. 干净的构建 - 打开 xcode 然后按 Command + Shift + K


    1. 如果您使用的是nvm,请尝试将NODE_BINARY=node 替换为which node 命令的实际结果,在我的情况下看起来像这样:

    大声喊出这些答案: onetwothree

【讨论】:

    【解决方案3】:

    作为一种解决方法,降级到 Xcode 13.2.1 对我有用。在这个版本上一切正常。

    但是在 13.3 版本 - 我有这个问题

    【讨论】:

    • 是的,这也适用于我。我不知道为什么这个问题出现在 Xcode 的13.3 版本中。
    【解决方案4】:

    如果您可以这样做,请更新您的 React Native 版本。 0.67 版修复了这个问题。

    如果更新不是一个选项,最简单的解决方案是更新您的库搜索路径。

    在 Xcode 中选择您的项目,然后转到“构建设置”。向下滚动,直到看到“搜索路径”,最后是“库搜索路径”。 将"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" 替换为"$(SDKROOT)/usr/lib/swift"

    此解决方案的功劳归于 Vegaro,他将其发布为 HERE,如果这对您不起作用,我认为这是一个更具侵入性的选择。

    【讨论】:

      【解决方案5】:

      当我将 xcode 升级到 14.1 时,它对我有用。

      【讨论】:

        猜你喜欢
        • 2016-01-24
        • 2018-08-16
        • 2019-08-30
        • 2019-10-03
        • 1970-01-01
        • 1970-01-01
        • 2019-05-20
        • 2021-01-21
        • 1970-01-01
        相关资源
        最近更新 更多