[MonoTouch] Using Objective C Framework - Guidance Required

Jeff Stedfast jeff at xamarin.com
Tue Jan 31 20:05:48 UTC 2012


Hi Jeff,

It sounds like you'll have to create an Xcode project for this driver
library. That part shouldn't be too difficult. You'll want to pick the
"Static Library Project" project type in Xcode and then just add all
of the source files.

Once you've done that, the easiest way to build a Fat *.a file is to
use a Makefile like the one at
https://github.com/mono/monotouch-bindings/blob/master/ATMHud/binding/Makefile
(you'll need to replace references to "atmhud" with whatever your
library name is) and then run `make` in a terminal. The Makefile I
linked you to assumes that it is in a directory side-by-side with the
Xcode project directory. There's a way to do it in Xcode, too, but
from my Googling, it seemed quite a bit harder than my Makefile
solution (that's why I just wrote Makefiles for monotouch-bindings).

Now that you have a libBarCodeScanner.a (or whatever you decide to
call it), you'll need to write an API definition file like the one at
https://github.com/mono/monotouch-bindings/blob/master/ATMHud/binding/atmhud.cs

You really only need to bind the methods and classes that you'll
actually be using from your app, so keep that in mind if the native
API is extensive (and it sounds like it might be with 49 .h files).
This is where the link
http://docs.xamarin.com/ios/advanced_topics/binding_objective-c_types
comes in handy as it documents the syntax. I honestly found it easier
to simply look over existing examples from the monotouch-bindings
module in github to learn the general flow of these files.

If you find yourself stuck somewhere, feel free to send questions to
the list and I (or someone else) will try to answer them. I'm probably
the best person to ask if you have questions about the
monotouch-bindings Makefiles as I wrote them to make things simpler to
build the bindings.

The process seems a lot more daunting than it really is (although it
would have helped if the driver source came with an Xcode project
pre-made for you to at least build the .a).

Hope that helps,

Jeff

On Mon, Jan 30, 2012 at 8:12 PM, JB
<jeff.butterworth at softwareresults.com.au> wrote:
>
> OK. I am stumped on this one. I feel like I am way out of my depth :-( I am
> using MonoDevelop 2.8.6.3 and Monotouch 5.0.4.
>
> I have been given a barcode scanner hardware accessory that the iPhone plugs
> into. It has an SDK for working with the device. The SDK is a framework.
> There is a 'driver' file and 49 .h files. There is no .a file. The SDK
> instructions show how to add the framework to an xcode project and use it.
> Seems pretty straight forward. Except I am using MonoTouch :-)
>
> I've read:
> - http://docs.xamarin.com/ios/advanced_topics/binding_objective-c_types
> - http://docs.xamarin.com/ios/advanced_topics/linking_native_libraries
> -
> http://dantes-andreea.blogspot.com/2012/01/how-to-use-objective-c-library-in.html
>
> but they aren't making a lot of sense to me.
>
> The Binding Object C Types document seems to assume I already have a .a
> static library to use. So do I create a static library in xcode and simply
> add the framework to it and compile it? Will that be enough to give me
> access to the definitions in the 49 .h files of the framework?
>
> The document also talks about btouch. That seems to take a number of .cs
> files and generates a dll. The dll gets added to my real project. What
> happens to the .a file? If I am reading correctly that gets included with
> the LinkWith option?
>
> Where do the .cs files come from? There are 49 .h files? I don't translate
> each one of the individually do I? Do Xamarin provide tools to automate the
> generation of the files?
>
> A guiding hand would be appreciated. I can sort of see what needs to be done
> but think I just need a slap round the head to point me in the right
> direction!
>
> Cheers
>
> Jeff
>
>
> --
> View this message in context: http://monotouch.2284126.n4.nabble.com/Using-Objective-C-Framework-Guidance-Required-tp4343151p4343151.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch


More information about the MonoTouch mailing list