ShareKit with MonoTouch how?
Asked Answered
B

2

7

How do you use ShareKit with MonoTouch?

The MonoTouch Bindings project on GitHub seems to have bindings for ShareKit but I can't get them to work. I currently have an iPhone application developed using MonoTouch in MonoDevelop, but I have no idea how to actually get ShareKit into my application.

I've downloaded the MonoTouch Bindings project, but when I make in the ShareKit directory it seems to require ShareKit itself. I then downloaded ShareKit, but I'm not sure if I'm supposed to follow the installation instructions for integrating ShareKit into an XCode project or even whether I'm supposed to build ShareKit at all. I've tried "building" an empty iPhone application project with ShareKit but parts of the instructions are not up-to-date for the latest XCode, it seems, to I got stuck in the process. I'm trying to get this working but my experiences with XCode so far has been limited to what little's needed for MonoTouch development.

Or is there a "precompiled" ShareKit iOS binary that could be used with MonoTouch?

Could someone verify that ShareKit is actually usable with MonoTouch and walk me through the steps required for making it work?

Thanks in advance!

Bernat answered 4/6, 2012 at 10:24 Comment(0)
P
2

First did you download from getsharekit.com or are you using ShareKit 2.0? If you are using the DL from getsharekit then I highly recommend you upgrade first. Second here some basic installation instructions for getting ShareKit to work with MonoTouch:

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!

Pellegrini answered 13/6, 2012 at 17:31 Comment(6)
I don't care if this answer is correct, kudos for the effort!Benkley
Thanks hopefully it helps the OP! Also please up-vote if you think the answer helpsPellegrini
Wow! I'll test this tomorrow. Since the bounty runs out before then, I'll just accept this largely based on your efforts.Bernat
Nice. @iBradApps, can you test this yourself? I've bountied you. ;)Fraase
Thanks, this worked for me at least as far as iOS 5 goes. Remember that ShareKit 2.0 is now also a static library so that shall make things even easier for you! :)Pellegrini
Lastly, I would also follow what pierceboggan says too because some of his points are true when using ShareKit with MonoTouch.Pellegrini
O
5

Most of the time when getting going with bindings in MonoTouch you have to download the bindings (or SDK) of the actual library. For example, with the TestFlight bindings, you are required to download the SDK and place it in the same directory as the makefile. I haven't personally expieremented with ShareKit, but I suppose it would work the same way (I know for a fact most, if not all, of the bindings in the MT bindings GitHub project work that way). You shouldn't have to deal with Xcode at all. Just download the SDK, place it in the correct directory, and run the makefile. That should spit a DLL for you to reference for use with MonoTouch.

One of the limitations of using the ShareKit bindings is that, as far as I know, the UI adjustments must be done in Objective-C before you try and use the linker. If you are fine with the out-of-the-box UI, then I would go for it. Otherwise, there are plenty of other open-source libraries for creating a simple sharing dialog (and now that Twitter is built in to iOS, it is even easier).

Obscuration answered 8/6, 2012 at 15:43 Comment(1)
The main folder in the downloaded zip seems to be renamed into sharekit and placed inside (github.com/mono/monotouch-bindings/tree/master/ShareKit/…) folder.Gynecologist
P
2

First did you download from getsharekit.com or are you using ShareKit 2.0? If you are using the DL from getsharekit then I highly recommend you upgrade first. Second here some basic installation instructions for getting ShareKit to work with MonoTouch:

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!

Pellegrini answered 13/6, 2012 at 17:31 Comment(6)
I don't care if this answer is correct, kudos for the effort!Benkley
Thanks hopefully it helps the OP! Also please up-vote if you think the answer helpsPellegrini
Wow! I'll test this tomorrow. Since the bounty runs out before then, I'll just accept this largely based on your efforts.Bernat
Nice. @iBradApps, can you test this yourself? I've bountied you. ;)Fraase
Thanks, this worked for me at least as far as iOS 5 goes. Remember that ShareKit 2.0 is now also a static library so that shall make things even easier for you! :)Pellegrini
Lastly, I would also follow what pierceboggan says too because some of his points are true when using ShareKit with MonoTouch.Pellegrini

© 2022 - 2024 — McMap. All rights reserved.