Flutter 应用程序在 M2 MacBook Air 上构建失败,并出现 Rosetta 错误:“附加代码签名补充失败”

问题描述 投票:0回答:1

我在 M2 芯片 MacBook Air 上构建 Flutter 应用程序的 ipa 文件时遇到问题。该应用程序在我的 Mac Studio 上构建成功,但在笔记本电脑上总是失败并出现错误:

error: rosetta error: Attachment of code signature supplement failed: 1
/var/db/oah/696e0658733369639e73a08cf7f6dc139beb7664301bce347578c8abc0ea947d/5736a6a6d3f8f7c6d96e251fef39431e4470b986151c860a80189c719e1eaf9d/gen_snapshot_arm64.aot
Dart snapshot generator failed with exit code -6
Target aot_assembly_release failed: Exception: AOT snapshotter exited with code -6

我用来构建ipa的命令

flutter build ipa

我尝试了其他帖子中的以下建议答案。

干净重建

flutter clean
rm -rf ios/Pods
rm -rf ios/.symlinks
rm -rf ios/Flutter/Flutter.framework
rm -rf ios/Flutter/Flutter.podspec
flutter pub get
cd ios
pod install
flutter build ipa

重新安装rosetta

softwareupdate --install-rosetta

颤医生-v

[✓] Flutter (Channel stable, 3.24.4, on macOS 14.5 23F79 darwin-arm64, locale
    en-HK)
    • Flutter version 3.24.4 on channel stable at
      /Users/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (8 weeks ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/to/macos-android-setup for detailed
      instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed
      instructions).

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 131.0.6778.140
    ! Error: Browsing on the local area network for x's iPhone 15. Ensure
      the device is unlocked and attached with a cable or associated with the
      same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)
    ! Error: Browsing on the local area network for x’s iPad. Ensure the
      device is unlocked and attached with a cable or associated with the same
      local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)

[✓] Network resources
    • All expected network resources are available.

Flutter 创建一个新项目

copy-and-paste old code files to new folder
flutter pub get
cd ios
pod install

但它们似乎都不起作用。当我尝试使用 XCode 工具栏“产品->存档”进行存档时,出现完全相同的错误。如果有人对如何解决此 Rosetta 错误有任何见解,我们将非常感激。

flutter xcode rosetta apple-m2
1个回答
0
投票

解决方案

我两周前升级了操作系统(Sequoia 15.0 至 15.1),但仍然无法构建 IPA 文件。我最初认为升级操作系统没有帮助。

今天,我检查了操作系统和 Xcode 的更新。有可用更新(OS 15.2 和 Xcode 16.2)。升级操作系统和Xcode,然后重新启动后,错误消息消失了。

建议

始终确保您的操作系统和 Xcode 是最新的。

© www.soinside.com 2019 - 2024. All rights reserved.