question

NickSherman-5788 avatar image
0 Votes"
NickSherman-5788 asked LeonardHarris-3315 edited

Xamarin Forms - iOS Binding - broken?

Last year I converted a Native iOS SDK for Epson receipt printers to a static binding library (*.a) to use within our Xamarin Forms suite of apps. It was a little tricky but I eventually got it working. I returned recently to the iOS version of the app to find it was broken, despite nothing having changed in the code or setup.

Essentially, within the iOS-specific code, I can now only see the enums belonging to the SDK namespace, not the classes & methods. I have tried messing around with assembly names, title, namespaces etc, but to no avail. I know that this did work at some stage but something has either changed in VS/XF/my system to cause this. At the moment we are just having to comment out this SDK-specific code while we work on other areas of the app.

I've tried looking for everything I can find on Google and as far as I can see it should be setup correctly - the trickiest part initially was fixing the ApiDefinition.cs file as Objective Sharpie only gets you part of the way.

The repo below contains a brand new Xamarin.Forms project, with just an iOS head and the iOS binding project referenced in the same way as used to work in our production app. If anyone can shed some light on this I would be extremely grateful. If you load the project in VS and look in the AppDelegate file, you should see that the Epos2Printer reference is underlined in red....

https://github.com/1888games/XF_Binding_Test/


dotnet-xamarin
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Would you believe it, a fix came out today as part of VS 16.9.5!

https://developercommunity.visualstudio.com/t/Building-Xamarin-iOS-binding-project-not/1361154

EDIT: It briefly worked, I could see my ePOSBinding namespace and its classes. Then I tried to import a new binding library and everything broke again, even after reverting to the working commit. Now I can't even see the ePOSBinding namespace, let alone its classes.

1 Vote 1 ·

In your repro ePOSBinding library is not found , so we can't test it, could you upload it first?

0 Votes 0 ·

Thanks for the reply - sorry, I'd forgotten the library was referenced from outside. The .a file gets me into LFS territory so I've just zipped up the project:

https://drive.google.com/file/d/1tydAGYx9RlZfTe2O3ga0rIzVgwm9v-wx/view?usp=sharing

0 Votes 0 ·

I don't know if I'm missing something really obvious, but if I open this official sample project on a brand new Windows 10 installation, VS2 2019 installation with Xamarin component, I get the same sort of issue, nothing in the XMBindingLibrary namespace is available within the iOS head.

https://docs.microsoft.com/en-us/samples/xamarin/ios-samples/bindingsample/

I noticed that within the APIDefinition.cs file, the enum defined in the Structs.cs file is not visible despite them existing within the same namespace. I had this issue in my project too and had to literally move all the enums/structs into the ApiDefinition file, which may well have been papering over a crack.

Opening the same project on VS for Mac 8.8.7 results in the same problem, after resolving an issue where an interface and class have the same name. Currently installing VS 2017.

0 Votes 0 ·

I am experiencing the same issue with my binding libraries I created a while ago. It seems to me that the ApiDefinition.cs (i.e. the file used as ObjcBindingApiDefinition) is simply ignored: Even syntax errors in this file lead to a successful but unusable build with no namespace included.

Might this be a bug of the current VS 16.9.4?

0 Votes 0 ·

I thought that too, I tried VS2017 and had similar problems but then I don't know if that's too old to even work.

I'll ask my boss tomorrow if we have an enterprise license for VS, if so we can download a slightly older version of VS and try that.

I've tried winding the project back to a commit from about a year ago to eliminate upgrading XF itself as a cause, that had the same issue.

0 Votes 0 ·

1 Answer

NickSherman-5788 avatar image
0 Votes"
NickSherman-5788 answered LeonardHarris-3315 edited

The solution (or rather workaround...) appears to be to remove the binding project from your solution, and then reference directly to the .dll in the bin folder of the binding project.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You could file a problem with feed hud or visual sutdio and report this directly to the team .

0 Votes 0 ·

@NickSherman-5788 @ColeXia-MSFT this issue is apparently resolved and awaiting release see following:

https://developercommunity.visualstudio.com/t/Cannot-reference-iOS-binding-Library-fro/1416767

https://developercommunity.visualstudio.com/t/Building-Xamarin-iOS-binding-project-not/1361154

I haven't bothered to check if the fix has actually been issued yet. however while my project works with the binding library reference reluctant to change this at the moment,

0 Votes 0 ·