Building for macOS target fails when installed from website, codesigning fails with “bundle format is ambiguous”

Update by @christopherfujino
This was caused by a bug in the script that generates the SDK packages for the website not properly handling symlinks. If your current install is affected, you can fix it by:

  1. Downloading the latest stable or beta packages from the website.
  2. Issuing the command: $ rm -rf path/to/flutter/bin/cache/artifacts/engine/darwin-x64* in your flutter repo, to delete the bad artifacts. The next time you issue flutter run or flutter build, the tool will identify that the artifacts are missing, and re-download them correctly.

I am new to Flutter. I am trying to follow the steps in Test Drive to build a macOS app, but the macos_assemble.sh script is failing:

 codesign --force --verbose --sign - -- /Users/peter/flutter/myapp/build/macos/Build/Products/Debug/myapp.app/Contents/Frameworks/FlutterMacOS.framework/FlutterMacOS
 /Users/peter/flutter/myapp/build/macos/Build/Products/Debug/myapp.app/Contents/Frameworks/FlutterMacOS.framework/FlutterMacOS: replacing existing signature
 /Users/peter/flutter/myapp/build/macos/Build/Products/Debug/myapp.app/Contents/Frameworks/FlutterMacOS.framework/FlutterMacOS: bundle format is ambiguous (could be app or framework)

To reproduce:

  1. flutter create myapp
  2. cd myapp
  3. flutter run
  4. choose macOS

System is macOS 11.2.1, Xcode 12.4 (12D4e), Intel MBP

Logs

Verbose logs are at this gist

flutter doctor -v
[✓] Flutter (Channel stable, 2.0.0, on macOS 11.2.1 20D74 darwin-x64, locale en-US)
    • Flutter version 2.0.0 at /Users/peter/flutter/flutter
    • Framework revision 60bd88df91 (3 hours ago), 2021-03-03 09:13:17 -0800
    • Engine revision 40441def69
    • Dart version 2.12.0

[✗] 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/docs/get-started/install/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 at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] 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/docs/get-started/install/macos#android-setup for detailed instructions).

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.1 20D74 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 88.0.4324.192

! Doctor found issues in 2 categories.

2 thoughts on “Building for macOS target fails when installed from website, codesigning fails with “bundle format is ambiguous”

  1. @sensuikan1973 The fix will make it to beta very soon. dev is never hotfixed, so the next dev will contain the fix.

    If you hit this issue on any channel, the workaround is:

    $rm -rf path/to/flutter/bin/cache/artifacts/engine/darwin-x64*
    

    Then try building your macOS app again.