xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.49k stars 515 forks source link

Binding libraries loads without generated compiled items in DesignTimeBuild mode #20814

Closed xtmq closed 5 months ago

xtmq commented 5 months ago

Steps to Reproduce

  1. Take any iOS binding library project, for example for net8.0-ios target framework
  2. Load it in DesignTimeBuild mode

Expected Behavior

It is loaded correctly and IDE is able to analyze it content

Actual Behavior

Files /obj/Debug/net8.0-ios/iOS/<ProjectName>/<Component>.g.cs is not added to MSBuild project

Build Logs and Example Project

Can be found in the Rider Issue Tracker: https://youtrack.jetbrains.com/issue/RIDER-94830

Investigation

For some reason these generated files are collected only during real build and ignored in design time mode so IDE can not collect and analyze them for some reason:

image

rolfbjarne commented 5 months ago

This is a known issue, many years ago we disabled the design-time build for binding projects.

It's because building a binding project requires a Mac, and when building remotely from Windows, it would require connecting to the Mac, building there, and getting the result back to the Windows machine. Design time builds are supposed to be fast... so the experience was less than ideal.

The good news is that we're working on building binding projects fully on Windows, and once that's done, we'll also enable design-time builds for binding projects.

That work is tracked here: https://github.com/xamarin/xamarin-macios/issues/10148, so I'm closing this as a duplicate of that issue.

xtmq commented 5 months ago

If this work will take some time, maybe we add a special property which IDE will be able to set to enable generating in .net 9 SDK?

xtmq commented 5 months ago

Alternativelly we can include in design-time build only collecting already generated files from obj folder. In that case if user performed full build and files were already generated IDE would be able to include and analyze bindings. As far as I remember it is implemented in android in that way...

rolfbjarne commented 5 months ago

If this work will take some time, maybe we add a special property which IDE will be able to set to enable generating in .net 9 SDK?

You can modify your local file with the _CollectGeneratedSources target to see if this would work.

xtmq commented 5 months ago

Removing condition from _CollectGeneratedSources helps