Nimrodda / flutter_nsd

A Flutter plugin that enables Network Service Discovery (mDNS) on various platforms via their native APIs.
Apache License 2.0
34 stars 8 forks source link

Error on executing command 'flutter build windows' #46

Closed andreasgolser closed 12 months ago

andreasgolser commented 1 year ago

Hi, I am trying to create a release build of a flutter project with flutter_nsd package

When I build this project for web (flutter build web) seems to be working. On building for Windows (flutter build windows) I get an error:

used version of package: flutter_nsd: ^1.4.0

flutter --version Flutter 3.13.1 • channel stable • https://github.com/flutter/flutter.git Framework • revision e1e47221e8 (28 hours ago) • 2023-08-22 21:43:18 -0700 Engine • revision b20183e040 Tools • Dart 3.1.0 • DevTools 2.25.0

flutter build windows

C:\temp\cnc-client\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(104,92): error C2220: the following warning is treated as an error [C:\temp\cnc-client\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\cnc-client\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(104,92): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\cnc-client\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\cnc-client\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(104,120): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\cnc-client\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\cnc-client\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(164,47): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\cnc-client\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\cnc-client\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(164,66): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\cnc-client\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] Building Windows application... 67,5s Build process failed.

Workaround: Edit Windows/CMakelists.txt Original:
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") to replace with: target_compile_options(${TARGET} PRIVATE /W4 /wd"4100")

Nimrodda commented 1 year ago

Have you tried to build the example app in debug/release on windows? Also note that your compiler is configured to treat warnings as errors. Try disabling that.

andreasgolser commented 1 year ago

Hi, I can reproduce this issue when I try to compile the example app...

FYI: To build I had to change cupertino_icons to 1.0.5 this should be no problem..

Output: Changed 23 dependencies! Resolving dependencies in .\example... The current Dart SDK version is 3.1.0.

Because cupertino_icons 0.1.3 doesn't support null safety and no versions of cupertino_icons match >0.1.3 <0.2.0, cupertino_icons ^0.1.3 is forbidden. So, because flutter_nsd_example depends on cupertino_icons ^0.1.3, version solving failed.

The lower bound of "sdk: '>=2.0.0-dev.28.0 <3.0.0'" must be 2.12.0 or higher to enable null safety. For details, see https://dart.dev/null-safety

fake_async 1.3.1 (was 1.3.0) flutter_lints 1.0.4 (2.0.2 available) flutter_nsd 1.4.0 from path .. (was 1.3.3 from path ..) lints 1.0.1 (2.1.1 available) matcher 0.12.16 (was 0.12.11) material_color_utilities 0.5.0 (was 0.1.4) (0.8.0 available) meta 1.9.1 (was 1.7.0) path 1.8.3 (was 1.8.1) source_span 1.10.0 (was 1.8.2) stack_trace 1.11.0 (was 1.10.0) (1.11.1 available) stream_channel 2.1.1 (was 2.1.0) (2.1.2 available) string_scanner 1.2.0 (was 1.1.0) term_glyph 1.2.1 (was 1.2.0) test_api 0.6.0 (was 0.4.9) (0.6.1 available) vector_math 2.1.4 (was 2.1.2)

  • web 0.1.4-beta These packages are no longer being depended on:
  • charcode 1.3.1 Changed 21 dependencies!

windows/runner/Runner.rc does not use Flutter version information, updating. C:\temp\flutter_nsd-master\example\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(104,92): error C2220: the following warning is treated as an error [C:\temp\flutter_nsd-master\example\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\flutter_nsd-master\example\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(104,92): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\flutter_nsd-master\example\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\flutter_nsd-master\example\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(104,120): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\flutter_nsd-master\example\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\flutter_nsd-master\example\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(164,47): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\flutter_nsd-master\example\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] C:\temp\flutter_nsd-master\example\windows\flutter\ephemeral.plugin_symlinks\flutter_nsd\windows\flutter_nsd_plugin.cpp(164,66): warning C4834: discarding return value of function with 'nodiscard' attribute [C:\temp\flutter_nsd-master\example\build\windows\plugins\flutter_nsd\flutter_nsd_plugin.vcxproj] Building Windows application... 32,1s Build process failed. PS C:\temp\flutter_nsd-master\example>