Sharekit integration MonoTouch

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Sharekit integration MonoTouch

kpijnenburg
Hi,

I'm used to work with ShareKit when building Obj-C iPhone apps. Has someone worked on binding Sharekit with MonoTouch?
Or maybe a decent Twitter / Facebook binding?

Would be willing to bind ShareKit myself, but have too little experience (yet) to build Sharekit into a static library .a.

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Sharekit integration MonoTouch

stevek
I have managed to get a very basic binding working, but there seem to be some issues with the more button. They may be related to this bug http://bugzilla.xamarin.com/show_bug.cgi?id=390.


Here's what I did (taken from our internal dev wiki):

>>>>>>>>>>>>>>>>>>>>>>

Basically 20 steps

1) Download the code

2) Open in Xcode and if its an App create a new Xcode project of type iOS library

3) Compile the library and take note of the frameworks needed - these will help you later when linking in monotouch

3) Compile a i386 Sim version of the lib and rename to libXYZLib_Sim.a - copy this to /Lib in your project and set its build action to None. You can find this under /ProjectLib/build/Debug-iphonesimulator/

4) Compile a arm6 version with the correct version & copy this to /Lib in your project and set its build action to None. You can find this under /ProjectLib/build/Debug-iphoneos/

5) Run the NovellHeaderParser like so against the library directories that contain .h files

@@
mono "/Users/XX/Projects/NovellHeaderParser/NovellHeaderParser/bin/Debug/NovellHeaderParser.exe" /Users/XX/Documents/ShareKitLib/ShareKit/Core
@@

this should produce a MonoMac.cs file that you can import into your system

6) Repeat step 5 for other directories. NOTE you will really only have to run the parser against .h files with entry points e.g. top level classes that the API calls directly. subclasses, utils, helper methods don't need to be parsed.

7) Combine all the MonoMac.cs files into a new MyLib.cs file and add that to the project under /Lib - set its build options to None

8) Change any references from MonoMac to MonoTouch

10) The parser *might* create a enum.cs file for each directory parsed but if not create your own called MyLibEnum.cs with any structs or enums needed by the API - add it to /Lib and set build options to None

11) Open a terminal window and navigate to the /Lib dir of your project

12) run the following btouch command line - this will create a wrapper.dll from the interfaces defined in MyLib.cs
@@
/Developer/MonoTouch/usr/bin/btouch -v MyLib.cs -s MyLibEnum.cs
@@


13) Add any missing enums or structs to MyLibEnum.cs and repeat Step 12

14) Fix any multiple declarations of selectors by renaming them - this may cause a problem later (see note 1)

15) Fix any missing references e.g. NSMutableArray does not seem to exist in monotouch so I change these to NSArrays (I think these are mutable under monotouch anyway???)

16) Go back to 12) and repeat until a dll is generated.

17) Add a reference to the dll into the project

18) Add the following into the iPhone Build> additional mtouch options TO THE SIMULATOR DEBUG/RELEASE BUILD:
@@
-gcc_flags "-L${ProjectDir}/Lib -lMyLib_Sim -framework QuartzCore -framework CoreGraphics -framework MessageUI  -framework Security -framework UIKit -framework CFNetwork -force_load ${ProjectDir}/Lib/libMyLib_Sim.a -ObjC"
@@

'''Notice'''

no trailing / on -L${ProjectDir}/Lib

-lShareKitLib_Sim does not need need the starting lib prefix or .a suffix

add one -framework for each framework used in the creation of the lib - above is not an exaustive list

19) Add the following into the iPhone Build> additional mtouch options TO THE IPHONE DEBUG/RELEASE BUILD:
@@
-gcc_flags "-L${ProjectDir}/Lib -lMyLib -framework QuartzCore -framework CoreGraphics -framework MessageUI  -framework Security -framework UIKit -framework CFNetwork -force_load ${ProjectDir}/Lib/libMyLib.a -ObjC"
@@


20) TEST IT!

NOTE 1 - btouch cant seem to tell the difference between selector "aselector" and "aselector:"
eg where 1 selector takes no arguments with the same name and another takes 1. This does not happen too often as normally Obj-C has selectors like dosomething:withsomethingelse:
If you have access to the source code it may be better to fix the selectors and re-build before trying the binds.
e.g. 1 called "aselector" and 1 called  "aselectorwithbool:"

>>>>>>>>>>>>>>>>>>>>>>>>>>