nativeshell / examples

Other
64 stars 7 forks source link

Build errors on macOS and Linux #22

Open mz2 opened 1 year ago

mz2 commented 1 year ago

I am experiencing build errors when trying to build the example code of the following kind (loads more of these in the cargo build output:

  [ +676 ms] ../../../../../../lib/main_window.dart:7:1: Error: 'MenuItem' is imported from both 'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:nativeshell/src/menu.dart'.
  [        ] import 'package:nativeshell/nativeshell.dart';

This is after I edited pubspec.yaml to set the SDK version to 2.17.0 or newer, since without doing that there were loads of these errors:

  [        ] ../../../../../../../flutter/packages/flutter/lib/src/gestures/multidrag.dart:440:5: Error: The 'super-parameters' language feature is disabled for this library.
  [        ] Try removing the package language version or setting the language version to 2.17 or higher.
  [        ]     super.kind,
  [        ]     ^^^^^
mz2 commented 1 year ago

I was able to build the examples with the following tweaks:

in pubspec.yaml:

 environment:
-  sdk: ">=2.12.0-214.0.dev <3.0.0"
+  sdk: ">=2.17.0 <3.0.0"

in lib/main_window.dart and lib/pages/menu.dart:

-import 'package:nativeshell/nativeshell.dart';
+import 'package:nativeshell/nativeshell.dart' as nativeshell;

(+ a whole bunch of prexing individual nativeshell type references in both source code files with nativeshell.)

in Cargo.toml (this was needed at least on macOS with arm64 given the Flutter framework's universal binary containing the arm64 binary in the x64 folder, which is fixed in nativeshell_build on the main branch):

-nativeshell_build = { version = "0.1.13" }
+nativeshell_build = { git = "https://github.com/nativeshell/nativeshell.git" }

 [dependencies]
-nativeshell = { version = "0.1.13" }
+nativeshell = { git = "https://github.com/nativeshell/nativeshell.git" }

However, cargo run fails with the following:

thread 'main' panicked at 'Failed to add method acceptsFirstMouse:', /Users/mz2/.cargo/registry/src/github.com-1ecc6299db9ec823/objc-0.2.7/src/declare.rs:180:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
mz2 commented 1 year ago

Ah, the last problem I have I think is because I tried running with the beta version of the SDK, and they recently added this to Flutter engine itself: https://github.com/flutter/engine/pull/34093 ... I'll see if I can make this conditional.

mz2 commented 1 year ago

(I have posted a PR to resolve the last issue at https://github.com/nativeshell/nativeshell/pull/171 -- will post something for the examples repo as well...)

pschuegr commented 1 year ago

Thanks @mz2 for the build fixes. @knopp will you accept a PR with those changes? I'll file one if so.