Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running template on Mac with Apple Silicon #1

Closed
wilsonowilson opened this issue Jun 3, 2021 · 11 comments
Closed

Error running template on Mac with Apple Silicon #1

wilsonowilson opened this issue Jun 3, 2021 · 11 comments

Comments

@wilsonowilson
Copy link

I just tried to run the example project on an apple silicon mac, but cargo run produces this error:

Target debug_unpack_macos failed: Exception: Binary /Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-c8fe034cd50a97c9/out/flutter/./FlutterMacOS.framework/FlutterMacOS does not contain arm64.

All logs:

failed to run custom build command for `nativeshell_examples v0.1.0 (/Users/wilson/Developer/Play/examples)`

Caused by:
  process didn't exit successfully: `/Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-0c7a4a584dad4c99/build-script-build` (exit code: 101)
  --- stdout
  Build failed with error:
  Flutter Tool Failed!
  Status: ExitStatus(ExitStatus(256))
  Command: "\"flutter\" \"assemble\" \"--output=.\" \"--define=BuildMode=debug\" \"--define=TargetPlatform=darwin\" \"--define=DarwinArchs=arm64\" \"--define=TargetFile=../../../../../../lib/main.dart\" \"-v\" \"--suppress-analytics\" \"debug_macos_bundle_flutter_assets\""
  Stderr:
  [   +5 ms] Target debug_unpack_macos failed: Exception: Binary /Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-c8fe034cd50a97c9/out/flutter/./FlutterMacOS.framework/FlutterMacOS does not contain arm64. Running lipo -info:
             Non-fat file: /Users/wilson/Developer/Play/examples/target/debug/build/nativeshell_examples-c8fe034cd50a97c9/out/flutter/./FlutterMacOS.framework/FlutterMacOS is architecture: x86_64

             #0      UnpackMacOS._thinFramework (package:flutter_tools/src/build_system/targets/macos.dart:97:7)
             #1      UnpackMacOS.build (package:flutter_tools/src/build_system/targets/macos.dart:76:5)
             #2      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:836:27)
             <asynchronous suspension>
             #3      Future.wait.<anonymous closure> (dart:async/future.dart)
             <asynchronous suspension>
             #4      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:774:32)
             <asynchronous suspension>
             #5      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:603:16)
             <asynchronous suspension>
             #6      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:314:32)
             <asynchronous suspension>
             #7      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1126:27)
             <asynchronous suspension>
             #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
             <asynchronous suspension>
             #9      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
             <asynchronous suspension>
             #10     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
             <asynchronous suspension>
             #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
             <asynchronous suspension>
             #12     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
             <asynchronous suspension>
             #13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
             <asynchronous suspension>
             #14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
             <asynchronous suspension>
             #15     main (package:flutter_tools/executable.dart:91:3)
             <asynchronous suspension>

  [   +4 ms] 
             #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
             #1      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:331:7)
             <asynchronous suspension>
             #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1126:27)
             <asynchronous suspension>
             #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
             <asynchronous suspension>
             #4      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
             <asynchronous suspension>
             #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
             <asynchronous suspension>
             #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
             <asynchronous suspension>
             #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
             <asynchronous suspension>
             #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
             <asynchronous suspension>
             #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
             <asynchronous suspension>
             #10     main (package:flutter_tools/executable.dart:91:3)
             <asynchronous suspension>



  Stdout:
  [ +150 ms] executing: sysctl hw.optional.arm64
  [  +38 ms] Exit code 0 from: sysctl hw.optional.arm64
  [   +3 ms] hw.optional.arm64: 1
  [   +7 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
  [  +26 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
  [        ] 320f27713bc843be7024b8e4216ab31a67e352ad
  [   +1 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git tag --points-at 320f27713bc843be7024b8e4216ab31a67e352ad
  [  +59 ms] Exit code 0 from: git tag --points-at 320f27713bc843be7024b8e4216ab31a67e352ad
  [   +2 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git describe --match *.*.* --long --tags 320f27713bc843be7024b8e4216ab31a67e352ad
  [  +57 ms] Exit code 0 from: git describe --match *.*.* --long --tags 320f27713bc843be7024b8e4216ab31a67e352ad
  [        ] 2.3.0-16.0.pre-180-g320f27713b
  [  +10 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
  [  +17 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
  [        ] origin/master
  [        ] executing: [/Users/wilson/Developer/SDK/flutter/] git ls-remote --get-url origin
  [  +16 ms] Exit code 0 from: git ls-remote --get-url origin
  [        ] https://github.com/flutter/flutter.git
  [  +81 ms] executing: [/Users/wilson/Developer/SDK/flutter/] git rev-parse --abbrev-ref HEAD
  [  +30 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
  [        ] master
  [   +7 ms] executing: sw_vers -productName
  [  +17 ms] Exit code 0 from: sw_vers -productName
  [        ] macOS
  [        ] executing: sw_vers -productVersion
  [  +16 ms] Exit code 0 from: sw_vers -productVersion
  [        ] 11.3
  [        ] executing: sw_vers -buildVersion
  [  +16 ms] Exit code 0 from: sw_vers -buildVersion
  [        ] 20E232
  [ +183 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
  [   +3 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
  [ +127 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
  [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
  [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
  [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
  [   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
  [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
  [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
  [  +38 ms] Initializing file store
  [   +8 ms] Done initializing file store
  [  +47 ms] Skipping target: gen_localizations
  [  +16 ms] Skipping target: gen_dart_plugin_registrant
  [   +6 ms] Skipping target: debug_macos_framework
  [   +1 ms] debug_unpack_macos: Starting due to {}
  [ +441 ms] Skipping target: kernel_snapshot
  [   +6 ms] Persisting file store
  [   +9 ms] Done persisting file store
  [  +17 ms] "flutter assemble" took 772ms.
  [  +10 ms] ensureAnalyticsSent: 6ms
  [   +1 ms] Running shutdown hooks
  [        ] Shutdown hooks complete
  [   +2 ms] exiting with code 1


  --- stderr
  thread 'main' panicked at 'explicit panic', build.rs:26:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@wilsonowilson wilsonowilson changed the title Error trying to run example on Mac with Apple Silicon Error running template on Mac with Apple Silicon Jun 3, 2021
@knopp
Copy link
Contributor

knopp commented Jun 3, 2021

This one is a bit tricky. Flutter doesn't ship with ARM64/Universal version of engine yet. The engine can now build natively for ARM64, but the build infrastructure is not yet setup to produce universal binaries: flutter/flutter#81488

So in your case cargo produces ARM64 build, but can't link with X86_64 engine.

You can try running the project with cargo run --target=x86_64-apple-darwin to see if it works. It should in theory but I haven't tried this yet, the build script might needs some fixing.

Alternatively you can build your own ARM64 version of flutter engine, but that's a bit more work.

@knopp
Copy link
Contributor

knopp commented Jun 3, 2021

Btw. You might need to install x86_64 toolchain to rust before you do this:

rustup target add x86_64-apple-darwin

Since you're cross-compiling from aarch64 to x86_64.

@wilsonowilson
Copy link
Author

wilsonowilson commented Jun 3, 2021

Thanks for the quick reply! It seems like that did the trick, but I'm getting another error that I think is unrelated.

2021-06-03 15:35:12.300 app_template[44200:579050] *** Assertion failure in -[FlutterViewController configureTrackingArea], ../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm:399
fatal runtime error: Rust cannot catch foreign exceptions
zsh: abort      cargo run --target=x86_64-apple-darwin

@knopp
Copy link
Contributor

knopp commented Jun 3, 2021

That one is indeed unrelated. Which flutter version do you have installed?

@wilsonowilson
Copy link
Author

2.3.0-17.0.pre.180 master.
Flutter doctor:

[✓] Flutter (Channel master, 2.3.0-17.0.pre.180, on macOS 11.3 20E232 darwin-arm, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.56.2)
[✓] Connected device (3 available)

@knopp
Copy link
Contributor

knopp commented Jun 3, 2021

I see. The assertion to [FlutterViewController configureTrackingArea] was added just two days ago so I missed it. I'll look into it now.

@wilsonowilson
Copy link
Author

Ah, you're right. Is there any way to manually configure the location of the Flutter SDK that nativeshell uses?

@knopp
Copy link
Contributor

knopp commented Jun 3, 2021

It uses current master :) It just that I haven't updated mine in a week and it so happened that there was a breaking change I didn't expect. Eventually it should work with dev/stable.

I should able to publish updated NativeShell crate that fixes the crash in maybe 20 minutes.

@wilsonowilson
Copy link
Author

Gotcha! Since this new issue is completely unrelated I guess I can close this now.

bk-one added a commit to bk-one/nativeshell that referenced this issue Jun 3, 2021
Run into the same error as in nativeshell#1 - thought it's better to update the README.
@knopp
Copy link
Contributor

knopp commented Jun 3, 2021

I published NativeShell 0.1.1. Can you update the examples and try running it again?

@wilsonowilson
Copy link
Author

Works like a charm! Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants