Twilio Voice Objective sharpie binding issue

ChrisLamont.3643ChrisLamont.3643 USUniversity ✭✭

I am using the Twilio Voice iOS library with Xamarin

As of now, it's beta version 19.

I'm using this command

 sharpie bind -output TwilioBeta19 -namespace TwilioBeta19 -sdk iPhoneOS10.3 /Users/lamont/Desktop/TwilioVoiceFramework/TwilioVoice.framework/Headers/*.h -scope /Users/lamont/Desktop/TwilioVoiceFramework/TwilioVoice.framework/Headers -c -F .

With this error, and output:

Question, how do I solve the error below?

Parsing 6 header files...
In file included from /var/folders/c6/w2rvd7zj0mx14pggh517lbb80000gn/T/tmp6a160417.h:1:
/Users/lamont/Desktop/TwilioVoiceFramework/TwilioVoice.framework/Headers/TVOCall.h:8:9: fatal error: 'Foundation.h' file not found
#import <Foundation.h>
        ^~~~~~~~~~~~~~

Binding...
  [write] ApiDefinitions.cs
  [write] StructsAndEnums.cs

Binding Analysis:
  Automated binding is complete, but there are a few APIs which have been flagged with [Verify] attributes. While the entire binding should be audited for best API design practices, look more closely
  at APIs with the following Verify attribute hints:

  ConstantsInterfaceAssociation (1 instance):
    There's no foolproof way to determine with which Objective-C interface an extern variable declaration may be associated. Instances of these are bound as [Field] properties in a partial interface
    into a nearby concrete interface to produce a more intuitive API, possibly eliminating the 'Constants' interface altogether.

  MethodToProperty (1 instance):
    An Objective-C method was bound as a C# property due to convention such as taking no parameters and returning a value (non-void return). Often methods like these should be bound as properties to
    surface a nicer API, but sometimes false-positives can occur and the binding should actually be a method.

  PlatformInvoke (5 instances):
    In general P/Invoke bindings are not as correct or complete as Objective-C bindings (at least currently). You may need to fix up the library name (it defaults to '__Internal') and return/
    parameter types manually to conform to C calling conventionsfor the target platform. You may find you don't even want to expose the C API in your binding, but if you do, you'll probably also want
    to relocate the definition to a more appropriate class and expose a stronger type-safe wrapper. For P/Invoke guidance, see http://www.mono-project.com/docs/advanced/pinvoke/.

  Once you have verified a Verify attribute, you should remove it from the binding source code. The presence of Verify attributes intentionally cause build failures.

  For more information about the Verify attribute hints above, consult the Objective Sharpie documentation by running 'sharpie docs' or visiting the following URL:

    http://xmn.io/sharpie-docs
1 error generated.
Error while processing /var/folders/c6/w2rvd7zj0mx14pggh517lbb80000gn/T/tmp6a160417.h.

Done. Exiting with error code 1.
error: Clang failed to parse input and exited with code 1
macos:~ lamont$ 

Answers

  • ChrisLamont.3643ChrisLamont.3643 USUniversity ✭✭

    I made progress, and made sure the include files were referencing Foundation/Foundation.h. I would love a better understanding of how this helped me proceed to step 2.

    I'm now stuck with the *.G files. Below is the (verify attribute fixed) version APIDefinition, the Structs, and the problematic *.G file.

    APIDefinition

    `
    using System;

    using UIKit;
    using Foundation;
    using ObjCRuntime;
    using CoreGraphics;

    namespace TwilioVoiceBindingBeta19
    {
    // @interface TVOCall : NSObject
    [BaseType(typeof(NSObject))]
    [DisableDefaultCtor]
    interface TVOCall
    {
    [Wrap("WeakDelegate")]
    [NullAllowed]
    TVOCallDelegate Delegate { get; set; }

        // @property (nonatomic, weak) id<TVOCallDelegate> _Nullable delegate;
        [NullAllowed, Export("delegate", ArgumentSemantic.Weak)]
        NSObject WeakDelegate { get; set; }
    
        // @property (readonly, nonatomic, strong) NSString * _Nonnull from;
        [Export("from", ArgumentSemantic.Strong)]
        string From { get; }
    
        // @property (readonly, nonatomic, strong) NSString * _Nonnull to;
        [Export("to", ArgumentSemantic.Strong)]
        string To { get; }
    
        // @property (readonly, nonatomic, strong) NSString * _Nonnull sid;
        [Export("sid", ArgumentSemantic.Strong)]
        string Sid { get; }
    
        // @property (getter = isMuted, assign, nonatomic) BOOL muted;
        [Export("muted")]
        bool Muted { [Bind("isMuted")] get; set; }
    
        // @property (readonly, assign, nonatomic) TVOCallState state;
        [Export("state", ArgumentSemantic.Assign)]
        TVOCallState State { get; }
    
        // -(void)disconnect;
        [Export("disconnect")]
        void Disconnect();
    
        // -(void)sendDigits:(NSString * _Nonnull)digits;
        [Export("sendDigits:")]
        void SendDigits(string digits);
    }
    
    // @interface CallKitIntegration (TVOCall)
    [Category]
    [BaseType(typeof(TVOCall))]
    interface TVOCall_CallKitIntegration
    {
        // @property (nonatomic, strong) NSUUID * _Nonnull uuid;
        [Export("uuid", ArgumentSemantic.Strong)]
        NSUuid Uuid { get; set; }
    }
    
    // @protocol TVOCallDelegate <NSObject>
    [Protocol, Model]
    [BaseType(typeof(NSObject))]
    interface TVOCallDelegate
    {
        // @required -(void)callDidConnect:(TVOCall * _Nonnull)call;
        [Abstract]
        [Export("callDidConnect:")]
        void CallDidConnect(TVOCall call);
    
        // @required -(void)call:(TVOCall * _Nonnull)call didFailToConnectWithError:(NSError * _Nonnull)error;
        [Abstract]
        [Export("call:didFailToConnectWithError:")]
        void CallDidFail(TVOCall call, NSError error);
    
        // @required -(void)call:(TVOCall * _Nonnull)call didDisconnectWithError:(NSError * _Nullable)error;
        [Abstract]
        [Export("call:didDisconnectWithError:")]
        void CallDidDisconnect(TVOCall call, [NullAllowed] NSError error);
    }
    
    // @interface TVOCallInvite : NSObject
    [BaseType(typeof(NSObject))]
    [DisableDefaultCtor]
    interface TVOCallInvite
    {
        // @property (readonly, nonatomic, strong) NSString * _Nonnull from;
        [Export("from", ArgumentSemantic.Strong)]
        string From { get; }
    
        // @property (readonly, nonatomic, strong) NSString * _Nonnull to;
        [Export("to", ArgumentSemantic.Strong)]
        string To { get; }
    
        // @property (readonly, nonatomic, strong) NSString * _Nonnull callSid;
        [Export("callSid", ArgumentSemantic.Strong)]
        string CallSid { get; }
    
        // @property (readonly, assign, nonatomic) TVOCallInviteState state;
        [Export("state", ArgumentSemantic.Assign)]
        TVOCallInviteState State { get; }
    
        // -(TVOCall * _Nullable)acceptWithDelegate:(id<TVOCallDelegate> _Nonnull)delegate;
        [Export("acceptWithDelegate:")]
        [return: NullAllowed]
        TVOCall AcceptWithDelegate(TVOCallDelegate @delegate);
    
        // -(void)reject;
        [Export("reject")]
        void Reject();
    }
    
    // @interface CallKitIntegration (TVOCallInvite)
    [Category]
    [BaseType(typeof(TVOCallInvite))]
    interface TVOCallInvite_CallKitIntegration
    {
        // @property (readonly, nonatomic, strong) NSUUID * _Nonnull uuid;
        [Export("uuid", ArgumentSemantic.Strong)]
        NSUuid Uuid { get; }
    }
    
    [Static]
    //[Verify(ConstantsInterfaceAssociation)]
    partial interface Constants
    {
        // extern NSString *const _Nonnull kTVOErrorDomain;
        [Field("kTVOErrorDomain", "__Internal")]
        NSString kTVOErrorDomain { get; }
    }
    
    // @protocol TVONotificationDelegate <NSObject>
    [Protocol, Model]
    [BaseType(typeof(NSObject))]
    interface TVONotificationDelegate
    {
        // @required -(void)callInviteReceived:(TVOCallInvite * _Nonnull)callInvite;
        [Abstract]
        [Export("callInviteReceived:")]
        void CallInviteReceived(TVOCallInvite callInvite);
    
        // @required -(void)notificationError:(NSError * _Nonnull)error;
        [Abstract]
        [Export("notificationError:")]
        void NotificationError(NSError error);
    }
    
    // @interface TwilioVoice : NSObject
    [BaseType(typeof(NSObject))]
    [DisableDefaultCtor]
    interface TwilioVoice
    {
        // @property (assign, nonatomic, class) TVOLogLevel logLevel;
        [Static]
        [Export("logLevel", ArgumentSemantic.Assign)]
        TVOLogLevel LogLevel { get; set; }
    
        // @property (copy, nonatomic, class) NSString * _Nonnull region;
        [Static]
        [Export("region")]
        string Region { get; set; }
    
        // +(NSString * _Nonnull)version;
        [Static]
        [Export("version")]
        //[Verify(MethodToProperty)]
        string Version { get; }
    
        // +(void)setModule:(TVOLogModule)module logLevel:(TVOLogLevel)level;
        [Static]
        [Export("setModule:logLevel:")]
        void SetModule(TVOLogModule module, TVOLogLevel level);
    
        // +(void)registerWithAccessToken:(NSString * _Nonnull)accessToken deviceToken:(NSString * _Nonnull)deviceToken completion:(void (^ _Nullable)(NSError * _Nullable))completion;
        [Static]
        [Export("registerWithAccessToken:deviceToken:completion:")]
        void RegisterWithAccessToken(string accessToken, string deviceToken, [NullAllowed] Action<NSError> completion);
    
        // +(void)unregisterWithAccessToken:(NSString * _Nonnull)accessToken deviceToken:(NSString * _Nonnull)deviceToken completion:(void (^ _Nullable)(NSError * _Nullable))completion;
        [Static]
        [Export("unregisterWithAccessToken:deviceToken:completion:")]
        void UnregisterWithAccessToken(string accessToken, string deviceToken, [NullAllowed] Action<NSError> completion);
    
        // +(void)handleNotification:(NSDictionary * _Nonnull)payload delegate:(id<TVONotificationDelegate> _Nonnull)delegate;
        [Static]
        [Export("handleNotification:delegate:")]
        void HandleNotification(NSDictionary payload, TVONotificationDelegate @delegate);
    
        // +(TVOCall * _Nullable)call:(NSString * _Nonnull)accessToken params:(NSDictionary<NSString *,NSString *> * _Nullable)twiMLParams delegate:(id<TVOCallDelegate> _Nonnull)delegate;
        [Static]
        [Export("call:params:delegate:")]
        [return: NullAllowed]
        TVOCall Call(string accessToken, [NullAllowed] NSDictionary<NSString, NSString> twiMLParams, TVOCallDelegate @delegate);
    }
    
    // @interface CallKitIntegration (TwilioVoice)
    [Category]
    [BaseType(typeof(TwilioVoice))]
    interface TwilioVoice_CallKitIntegration
    {
        // +(void)configureAudioSession __attribute__((availability(ios, introduced=10_0)));
        //[iOS(10, 0)]
        [Introduced(PlatformName.iOS, 10, 0, PlatformArchitecture.Arch64, null)] // Updated - CLM
        [Static]
        [Export("configureAudioSession")]
        void ConfigureAudioSession();
    
        // +(void)startAudio __attribute__((availability(ios, introduced=10_0)));
        //[iOS(10, 0)]
        [Introduced(PlatformName.iOS, 10, 0, PlatformArchitecture.Arch64, null)]// Updated - CLM
        [Static]
        [Export("startAudio")]
        void StartAudio();
    
        // +(void)stopAudio __attribute__((availability(ios, introduced=10_0)));
        [Introduced(PlatformName.iOS, 10, 0, PlatformArchitecture.Arch64, null)]// Updated - CLM
        [Static]
        [Export("stopAudio")]
        void StopAudio();
    }
    

    }
    `

    Structs

    `using System;
    using ObjCRuntime;

        namespace TwilioVoiceBindingBeta19
        {
            [Native]
            public enum TVOCallState : ulong // Maintenance note: Objective Sharpie put "nuint" type declaration here. Illegal in native iOS
            {
                Connecting = 0,
                Connected,
                Disconnected
            }
    
            [Native]
            public enum TVOCallInviteState : ulong // Maintenance note: Objective Sharpie put "nuint" type declaration here.  Illegal in native iOS
            {
                Pending = 0,
                Accepted,
                Rejected,
                Canceled
            }
    
            [Native]
            public enum TVOError :  ulong // Maintenance note: Objective Sharpie put "nuint" type declaration here.  Illegal in native iOS
            {
                AccessTokenInvalid = 20101,
                AccessTokenHeaderInvalid = 20102,
                AccessTokenIssuerInvalid = 20103,
                AccessTokenExpired = 20104,
                AccessTokenNotYetValid = 20105,
                AccessTokenGrantsInvalid = 20106,
                AccessTokenSignatureInvalid = 20107,
                ExpirationTimeExceedsMaxTimeAllowed = 20157,
                AccessForbidden = 20403,
                ApplicationNotFound = 21218,
                GenericError = 31000,
                ConnectionTimeout = 31003,
                InitializationError = 31004,
                MalformedRequest = 31100,
                InvalidData = 31106,
                AuthorizationError = 31201,
                InvalidJWTToken = 31204,
                RegistrationError = 31301
            }
    
            [Native]
            public enum TVOLogLevel :  ulong // Maintenance note: Objective Sharpie put "nuint" type declaration here.  Illegal in native iOS
            {
                Off = 0,
                Error,
                Warn,
                Info,
                Debug,
                Verbose
            }
    
            [Native]
            public enum TVOLogModule :  ulong // Maintenance note: Objective Sharpie put "nuint" type declaration here.  Illegal in native iOS
            {
                TVOLogModulePJSIP = 0
            }
        }
    

    `

    Error: Can't define instance members in a static class

    TVOCall_CallKitIntegration
    `

    using CoreAnimation;
    using CoreFoundation;

    namespace TwilioVoiceBindingBeta19 {
    public unsafe static partial class TVOCall_CallKitIntegration {

        [CompilerGenerated]
        static readonly IntPtr class_ptr = Class.GetHandle ("TVOCall");
    
        [CompilerGenerated]
        public virtual NSUuid Uuid {.  <---- ERROR HERE
            [Export ("uuid", ArgumentSemantic.Retain)]
            get {
                NSUuid ret;
                if (IsDirectBinding) {
                    ret =  Runtime.GetNSObject<NSUuid> (global::ApiDefinition.Messaging.IntPtr_objc_msgSend (this.Handle, Selector.GetHandle ("uuid")));
                } else {
                    ret =  Runtime.GetNSObject<NSUuid> (global::ApiDefinition.Messaging.IntPtr_objc_msgSendSuper (this.SuperHandle, Selector.GetHandle ("uuid")));
                }
                return ret;
            }
    

    `

  • Did you ever get this working?

Sign In or Register to comment.