链接的框架“Pods_Runner.framework”缺少此目标所需的一个或多个体系结构:x86_64。

21

我在使用M1 MacBook Pro通过IOS模拟器构建我的Flutter应用程序时遇到了以下错误。 我正在使用VS Code进行编辑。 当我连接我的iPhone到Mac并构建时,没有任何问题。 有什么办法可以解决这个问题。

输入图像描述

Launching lib/main.dart on IPhone 13 Simulator in debug mode...
lib/main.dart:1
Xcode build done.                                            1.5s
Failed to build iOS app
Error output from Xcode build:
↳
    objc[10488]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1ffeb6b90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1048c42c8). One of the two will be used. Which one is undefined.
    objc[10488]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1ffeb6be0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1048c4318). One of the two will be used. Which one is undefined.
    ** BUILD FAILED **
Xcode's output:
↳
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/aravindganesh/Documents/Development/myproject/ios/Runner.xcodeproj: error: The linked framework 'Pods_Runner.framework' is missing one or more architectures required by this target: x86_64. (in target 'Runner' from project 'Runner')
Could not build the application for the simulator.
Error launching application on IPhone 13 Simulator.
Exited (sigterm)

我在下面添加了x-code配置:

在此输入图像描述

10个回答

23

flutter clean 命令简单解决了我的问题。


1
在我升级Flutter 3.0.0到3.0.1之后,问题得到解决。 - Sebastian

17

Xcode 13.4

目标 > 构建设置 > 构建选项 > 允许多平台构建: YES

输入图像描述


2
这对我很有帮助。谢谢! - Reza Shirazian

16

我在我的M1 Mac上遇到了同样的问题,以下是我解决此问题的步骤:

  1. sudo arch -x86_64 gem install ffi
  2. 将此代码添加到位于 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/ && arch -x86_64 pod install.

  2. 使用 Rosetta 运行 Xcode。
    enter image description here.
    您可以通过运行以下命令来安装 Rosetta:softwareupdate --install-rosetta

  3. 排除 arm64 架构。 enter image description here

  4. 清理构建 - 打开 Xcode,然后按下 Command + Shift + K


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

感谢以下答案: 一个 两个 三个


2
步骤2、3、4和5都已完成,对我来说运行正常。 - Wahab Khan Jadon

2

这个问题与Xcode配置有关。进入项目工作区,然后打开Runner目标排除架构,并添加arm64以便在模拟器上运行应用程序。您的问题与此问题密切相关。


我已经做了更改。仍然出现相同的错误。/Users/aravindganesh/Documents/Development/sydneyiskcon/ios/Runner.xcodeproj: error: 此目标所需的一个或多个体系结构缺少链接框架“Pods_Runner.framework”:x86_64。(在项目“Runner”的目标中) - Aravind
1
你的问题与运行模拟器的架构(排除的架构)以及你在架构中包含的架构密切相关。请检查是否在架构中包含了$(ARCHS_STANDARD)。默认情况下应该是这样的。此外,请对Xcode配置中包含的架构进行更多的研究(i386、x86_64、armv7、arm64、i386),这些都是其中的一些,通常在你排除的架构中应该添加任何iOS模拟器SDK arm64和i386。希望能有所帮助。 - wesleyhodaj
我已经在问题中包含了IOS构建设置。 - Aravind

2

只需运行flutter upgrade命令。我解决了这个问题,升级了我的Flutter版本从2.8.0到2.10.0,并在Xcode中添加了排除arm64的设置。


2

我之前也遇到了同样的问题,但是已经解决了。

  1. 你可以尝试在构建设置(Build Settings) -> 架构(Architectures) -> 排除的架构(Excluded Architectures) 中添加arm64选项,这对许多开发人员有帮助,但对我没有用。

  2. 你可以清理构建文件夹(Clean Build Folder, ⇧ + ⌘ + K),清理DerivedData目录、CocoaPods缓存,并重启macOS、Xcode和模拟器。这个方法对我有效。


1

ios/ 试一下这个:

rm Podfile.lock Gemfile.lock
gem cleanup
gem update
pod install
open Runner.xcworkspace/  # Do the recommend fixes from the Xcode UI
flutter build ios

这通常对我遇到的大多数问题都管用。

1
问题在Xcode上也出现了。问题是IDE不能识别正确的架构。 在Xcode中打开搜索(command + space),然后输入“Xcode”。向下滚动并单击“在查找器中搜索”。 然后右键单击你的应用程序,在这种情况下 - 右键单击Xcode.app并单击“获取信息”。 MacM1上的每个应用程序都有一个“使用Rosetta打开”的按钮。勾选该框即可解决Xcode的问题。 我猜在Xcode之外的多个应用程序上也会出现相同的问题,也许包括VSCode。

1

我在我的M1上遇到了相同的问题,你可以通过以下方法解决:

cd ios && arch -x86_64 pod install && cd ../

那应该解决问题 :)

1

我刚刚通过将flutter版本从2.8.0降级到2.5.3来解决了这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接