Xamarin iOS binding with Swift framework fails on build

Luc MOUSSIEGT 1 Reputation point
2022-01-11T16:54:42.803+00:00

I encounter a problem building a Xamarin.iOS Binding library project.

So for context, I have to integrate a Swift framework (built with SDK iphoneos14.5) into a Xamarin project. The framework was delivered with Objective-C headers containing the required interface members, so I was able to use Objective Sharpie to generate the ApiDefinitions.cs and StructsAndEnums.cs files using the following command line:

sharpie bind -sdk iphoneos15.0 -scope MyFramework.framework/Headers/ -c -F. MyFramework.framework/Headers/MyFramework.h   

Now, I added the generated files in a new Xamarin.iOS Bindings solution. I added the framework MyFramework.framework as native reference to the project, changed native reference properties to enable "Smart Link", disable "Force Load", and add UIKit and Foundation to the Frameworks entry.

The issue I'm facing is with some class types that were referenced as forward declarations (@class declaration) in the headers of the framework, and that were ignored by Objective Sharpie. I suppose they are in the native library, but the line

using MyFramework;  

fails and outputs CS0246: type or namespace not found.

How am I supposed to solve this ? Should I create empty declarations for the missing types? Am i writing this using wrong?

Developer technologies | .NET | Xamarin
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.