Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

iOS Bindings Library - type or namespace name XXX could not be found

LeoJHarrisLeoJHarris NZMember ✭✭✭
edited March 2 in Xamarin.iOS

Hi all, reaching out the Xamarin.iOS Team here!

I am trying to create an iOS Bindings Library from this native xcode project but I have run into issues! Library to Bind: SDK https://github.com/square/in-app-payments-ios-quickstart/tree/master/Pods/SquareInAppPaymentsSDK/SquareInAppPaymentsSDK.framework

I have used Objective Sharpie to generate my ApiDefinition.cs and StructsAndEnums.cs from the native project with the terminal and that worked fine :smile: so no issues there as it would seem. Next I Created my Visual Studio iOS Bindings Library and copy and pasted the code into the existing files for ApiDefinitions.cs and StructsAndEnum.cs I checked the Build Action and its set to ObjcBindingApiDefinition and ObjcBindingCoreSource respectively, the native reference i.e. "SquareUnAppPaymentsSDK" is the .framework folder of the native project (second image) I had worked down my errors to about 5 but cannot figure out what is wrong and how to resolve them it should surely work!

This is the native project reference

My Errors:

BTOUCH : warning BI1117: bgen: The member 'SquarePaymentRequestWithMerchantIdentifier' is decorated with [Static] and its container class SquareinAppPaymentsSDKOut.PKPaymentRequest_Square is decorated with [Category] this leads to hard to use code. Please inline SquarePaymentRequestWithMerchantIdentifier into PassKit.PKPaymentRequest class.
BTOUCH : warning BI1060: bgen: The SquareinAppPaymentsSDKOut.SQIPCardEntryViewControllerDelegate protocol is decorated with [Model], but not [BaseType]. Please verify that [Model] is relevant for this protocol; if so, add [BaseType] as well, otherwise remove [Model].
/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Microsoft.Common.CurrentVersion.targets(3319,5): warning MSB9004: ManifestResourceWithNoCulture item type is deprecated. Emit EmbeddedResource items instead, with metadata WithCulture='false', Type='Resx', and optional LogicalName.
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/obj/Debug/ios/SquareinAppPaymentsSDKOut/SQIPCard.g.cs(76,27,76,31): warning CS8767: Nullability of reference types in type of parameter 'zone' of 'NSObject SQIPCard.Copy(NSZone zone)' doesn't match implicitly implemented member 'NSObject INSCopying.Copy(NSZone? zone)' (possibly because of nullability attributes).
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/obj/Debug/ios/SquareinAppPaymentsSDKOut/SQIPTheme.g.cs(89,27,89,31): warning CS8767: Nullability of reference types in type of parameter 'zone' of 'NSObject SQIPTheme.Copy(NSZone zone)' doesn't match implicitly implemented member 'NSObject INSCopying.Copy(NSZone? zone)' (possibly because of nullability attributes).
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/StructsAndEnums.cs(42,69,42,80): error CS0246: The type or namespace name 'NullAllowedAttribute' could not be found (are you missing a using directive or an assembly reference?)
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/StructsAndEnums.cs(42,69,42,80): error CS0246: The type or namespace name 'NullAllowed' could not be found (are you missing a using directive or an assembly reference?)
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/StructsAndEnums.cs(52,55,52,66): error CS0246: The type or namespace name 'NullAllowedAttribute' could not be found (are you missing a using directive or an assembly reference?)
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/StructsAndEnums.cs(52,55,52,66): error CS0246: The type or namespace name 'NullAllowed' could not be found (are you missing a using directive or an assembly reference?)
/Users/User/Source/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/SquareInAppPaymentsSDKOut/obj/Debug/ios/SquareinAppPaymentsSDKOut/SQIPCardEntryViewController.g.cs(124,10,124,45): error CS0246: The type or namespace name 'SQIPCardEntryViewControllerDelegate' could not be found (are you missing a using directive or an assembly reference?)
    5 Warning(s)
    5 Error(s)

Time Elapsed 00:00:01.77

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Build: 5 errors, 5 warnings

EDIT: Can now build project. I removed the NullAllowed attributes and that issue when a way but current thinking is that the native library was built with iphoneos12.2 (I think it was) and those attributes didn't exist in that earlier version? the SDK I am using now it iphoneos14.4... I would like to re-add them but do I need to recompile the native project in 14.4 from xcode?

Also I added [BaseType(typeof(UIViewController))] to the SQIPCardEntryViewControllerDelegate interface since it derived from UIViewController so that issue went away.

I also removed the [Static] attribute from SquarePaymentRequestWithMerchantIdentifier and that issue went away.

So I while I can build the project any feedback on the above would be appreciate...

Best Answer

Answers

  • LeoJHarrisLeoJHarris NZMember ✭✭✭
    edited March 2

    UPDATE: Got this working now, my knowledge with iOS binding libraries is limited but I might need to go back and tidy somethings up but still curious on the points regarding NullAllowed attributes and removing removing the [Static] attribute from SquarePaymentRequestWithMerchantIdentifier. Still interested to know if these should have been removed?

  • ColeXColeX Member, Xamarin Team Xamurai
    Accepted Answer

    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • LeoJHarrisLeoJHarris NZMember ✭✭✭

    Hi @ColeX and thanks for replying, I got the binding to build, I also was able to consume the blinding and verify that that the binding library worked in my iOS project as the API's were called and the expected UI was provided as per the native library :smile:

Sign In or Register to comment.