We used the LinkOS_Xamarin_SDK NuGet package in our Xamarin.Android and Xamarin.iOS apps to communicate with Zebra printers. We're now migrating our apps to .NET 8. It appears that LinkOS_Xamarin_SDK package isn't available to .NET 8. Zebra.Printer.SDK looks to be the replacement, but its API appears to be vastly different. Is there a more direct upgrade path, such as new bindings for the Java and Objective C libraries?
What's the suggested migration path from LinkOS_Xamarin_SDK?// Expert user has replied. |
6 Replies
The Zebra.Printer.SDK NuGet package has moved away from Xamarin to supporting .NET MAUI 8 with the latest release of v3.0.3271. The API themselves have not changed from the previous versions of v2.14.1869 and v2.15.2634, which supported Xamarin. The changes made in v3.0.3271 are mainly underneath the supporting dependences by shifting from .NET Framework 4.7 to .NET MAUI 8. Due to shifting in the dependencies, migrating a Xamarin project to .NET MAUI is not a simple or easy process, because the Xamarin form based implementation and code structure need to be removed or replaced.
Thanks. I get that the Zebra.Printer.SDK NuGet package itself likely hasn't changed much. My point is that we were using LinkOS_Xamarin_SDK version 1.2.0 instead of Zebra.Printer.SDK. Was there ever any guide for migrating from LinkOS_Xamarin_SDK to Zebra.Printer.SDK? For example, this is a valid line when using the Android version of LinkOS_Xamarin_SDK but would be very different when using Zebra.Printer.SDK:
IZebraPrinterConnection connection = new BluetoothPrinterConnection(macAddress);
After doing some looking around with DotPeek, I eventually found that the changes weren't as drastic as I was thinking on the Android side at least:
iOS is more problematic since LinkOS_Xamarin_SDK relied more heavily on iOS-specific classes. Most notably GraphicsUtil.StoreImage used to have an overload which accepts a CGImage, whereas it's looking like I'll need to fetch a Stream now from somewhere.
The Zebra.Printer.SDK is the recommended replacement for the LinkOS_Xamarin_SDK package in .NET 8, although the API is different. Zebra provides documentation and samples to help migrate your code, making this the most direct upgrade path. Creating your own bindings for the Java and Objective-C Zebra printer SDKs is an option, but it involves a significant amount of work and maintenance. Alternatively, you could evaluate using the Zebra.Printer.SDK directly in your .NET 8 apps without Xamarin, or rewriting your apps in .NET 8 using a cross-platform framework like Uno Platform or Avalonia. The best approach depends on the complexity of your apps and your willingness to adapt to the new SDK or rewrite your code.
Thanks
Regards
Unfortunately, for iOS I ultimately had to go back to using a binding for the Objective C ZSDK_API since the iOS version of Zebra.Printer.SDK is far too buggy:
Plus some smaller annoyances:
Migrating from Xamarin to .NET 8 is a significant step, especially when dealing with external SDKs like the LinkOS_Xamarin_SDK used for Zebra printers. As you noted, the LinkOS_Xamarin_SDK is not directly available in .NET 8, and Zebra has moved towards using the Zebra.Printer.SDK for newer .NET platforms. Unfortunately, this does involve a notable change in the API, making the transition less straightforward.
Given the significant API differences, the most stable and future-proof approach would be to migrate to Zebra.Printer.SDK and refactor your code accordingly. While it may require more upfront effort, it aligns with Zebra's ongoing support and future development, ensuring better compatibility and maintenance down the line.