question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mac Catalyst Binding Library not callable

See original GitHub issue

Description

It appears anything in the ApiDefinition.cs and StructsAndEnums.cs of a Mac Catalyst Binding Library is not callable from MAUI (or other) code.

With a barebones Mac Catalyst Binding Library containing only the following interface declaration:

    [BaseType(typeof(NSObject))]
    interface Widget
    {
    }

Strangely, in Visual Studio for Mac 2022 Preview 17.5 there is no syntax highlighting for BaseType and NSObject: image

I cannot reference this class or any other code defined in these files from either a MAUI app or any other class library: It cannot resolve the references. (“the type or namespace could not be found”)

If I create a separate class file within the Mac Catalyst Binding Library, then I am able to reference that class from MAUI with no issues. However, even within this separate class file I cannot reference code from the ApiDefinition.cs or StructsAndEnums (see file EmptyClass.cs in reproduction project repo)

In Xamarin.Mac it was possible to reference a Bindings Library in the way it currently fails for MAUI.

Note: In this example I am not actually adding a Native Framework to the Bindings Library, but I can confirm that in the ‘real’ project where I encountered this issue that I have the exact same issue when there is a proper Native Framework reference in the Bindings Library.

Steps to Reproduce

  1. Create new MAUI project
    • Disabling all-but Mac Catalyst functionality
  2. Create new Mac Catalyst Binding Library
    • Adding small interface definition to ApiDefinition.cs to test if it can be referenced
  3. Add reference to Mac Catalyst Binding Library from MAUI project
  4. Try to reference code from ApiDefinition.cs in the MAUI project, it will not resolve and the build will fail.

Link to public reproduction project repository

https://github.com/4or5trees/maui-macos-binding-problem

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

macOs 12.6, VS for Mac 2022 Preview 17.5

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rolfbjarnecommented, Dec 7, 2022

@drasticactions it’s a known issue that syntax highlighting doesn’t work properly when using binding projects as project references (https://github.com/xamarin/xamarin-macios/issues/10148). However, the solution should build just fine (although I also believe there are some issues with binding projects not quite working correctly on Windows, but that doesn’t seem to be the scenario here).

0reactions
4or5treescommented, Dec 7, 2022

@drasticactions Thank you very much! Referencing the built DLL of my bindings project fixes my issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - building for Mac Catalyst, but linking in object file built ...
Message sounds like " your library is built for Catalyst but my-file.cpp.o is built for macOS ". But it actually means:.
Read more >
Why none of the binding library's classes' methods are ...
I have a .NET MAUI app that needs to use custom native Android and iOS libraries. I was able to successfully create Android...
Read more >
Mac Catalyst Overview
Easily start creating a native Mac app from your current iPad app with Mac Catalyst.
Read more >
Untitled
Marine preamp, Curly hair cat ears, Pasquale palma non so, ... Tin phap luat daklak moi nhat, Virtual pc 2004 mac os x,...
Read more >
Programming biological models in Python using PySB.
Central to PySB is a library of macros encoding familiar biochemical actions such as binding, catalysis, and polymerization, making it possible to use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found