Forum Xamarin.iOS


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.

Objective-C binding tutorial

tescotttescott USMember ✭✭

I've looked through and have attempted to follow the Xamarin docs regarding binding Objective-C libraries but run into issues where it seems as if simple constructor execution is not occurring as expected. For example, I put NSLog() trace messages in the Objective-C code that I'm trying to use, but I don't see any log messages appear when I run my test in the iPhoneSimulator. I'm obviously doing something wrong. (FWIW, I'm trying to create MonoTouch bindings for this project:

I was wondering if anyone is aware of basic tutorials for defining Objective-C library bindings for MonoTouch. I think that'd help me figure out where I'm probably going wrong.



  • rogiheerogihee NLMember ✭✭✭
    edited December 2012

    I assume you have looked at:

    Also, it may help to take a look at existing bindings (helps me...):

  • tescotttescott USMember ✭✭

    Yep, I checked that out. I'm trying to duplicate what the user here did:

    Additionally, I created a project with a Makefile patterned after the Monotouch bindings for the facebook project from Github. I've created a 'fat' library that should allow me to run things on the simulator and device. My simple test program instantiates my example object. Yet, when I execute the 'getMessage()' method, it returns null instead of the string I expect. I added NSLog() to that method in the native library, and I do not see any log data appear. So, something is going wrong... I just haven't pinpointed what / where yet.


  • rogiheerogihee NLMember ✭✭✭

    I only begun writing my first binding yesterday, so I'm afraid I cannot be of much further assistance :-).


  • tescotttescott USMember ✭✭

    I'd be interested to know your progress... if you are able to get things to work.

    I need to investigate things further, but I was able to get the BindingSample project to work from this repo:

    The implementation looks slightly different (older?) than the recommended guidelines on the Xamarin site linked in your post above. If nothing else, I'm hoping to compare my current approach with the BindingSample project and see where I'm going astray.


  • tescotttescott USMember ✭✭

    Success! In my original makefile, I failed to include the 'linkwith.cs' file. Referencing that using the '-x' btouch switch got things to compile. Next, I needed to update the linkwith.cs file with the correct reference to my native library name. After that, everything worked. Wahoo! :)


Sign In or Register to comment.