Windows and Mac development

I am trying to develop an application that runs in Windows and on the Mac desktop. I realize these are rather old-fashioned requirements, but bear with me. I want to separate concerns so that the Windows and Mac "Views" can be built on top of an independent "Model", with an intervening "Controller" or "View Model". My background is in Windows, so I'm trying to develop as much as possible in C# (although I realize it will be necessary to familiarize myself with Mac development). I'm using Visual Studio Community Edition in Windows and on the Mac. The Visual Studio solution is checked into GitHub.

Having explored various possibilities, my current knowledge suggests the following sample architecture (let me know what you think):

  • A WPF application using .NET Framework 4.6.2.
  • A Mac application using Xamarin.Mac.
  • A shared library using .NET Standard 2.0.

I first created the WPF application and the .NET Standard library. Then I added the Mac application. On the Mac, the WPF application was automatically ignored, and Xamarin.Mac was able to successfully call a method in the shared library. However, when I went back to development in Windows, I got the following error in the Mac project:

Error CS0012 The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

This is an error in the code for the Mac project, yet there were no problems on the Mac. My inclination was not to fix this error on the Windows side, but rather to figure out if I could ignore the Mac project, mirroring the behavior on the Mac.

I did this by going to the solution's Properties, and deactivating the build for the Mac project. The solution now built successfully in Windows. But as you can imagine, my fear was that this would cause problems when I went back to the Mac.

Surprisingly, on the Mac, the Xamarin.Mac application continued to work. The only anomaly was that the Mac project showed a warning: "Project not built in active configuration".

So I now have a sample that fulfills my needs, except that I get a warning in Visual Studio for Mac. Is this just something I have to put up with, or is it a sign that I should be using a different architecture? If so, what should that architecture be?

Posts

  • joelin0joelin0 USMember

    I figured it out. I wasn't thinking clearly. I originally had one solution with both the WPF and Xamarin.Mac projects.

    Instead, I created two solutions, one with WPF and one with Xamarin.Mac. Each one uses the shared .NET Standard library.

    Version Control in Visual Studio for Mac is not working well, though. I had to run git from Terminal to push the initial Mac solution to GitHub, and even subsequent commits and pushes can only be done from Terminal.

    Now, on to unit tests!

Sign In or Register to comment.