First off, I'm fairly new to iOS, I've only been working with it a few months so my knowledge of the API and ObjC is fairly limited; I've read the docs from Xamarin and a few posts on the forums on how to do bindings to objective C libraries but I'm still having some issues.
My scenario is that I'm using a few custom libraries in one of our legacy iOS apps that I want to port over to Xamarin. Rather than link in the entire API of these libraries I just wanted to write a small Obj C wrapper that does what I want in these libs and expose a few methods to "bind" into my .net code.
I started small with this single function in Obj C: The class name in Obj C is "PODSUP", method signature is as follows:
+ (void) InitializeSUP : (NSString *)username password:(NSString *)password SAPID:(NSString *) SAPID;
I created a Binding Project in Xamarin, and put this in the ApiDefinition.cs file:
[BaseType (typeof (NSObject))]
public partial interface PODSUP
{
[Static, Export ("InitializeSUP:password:SAPID:")]
void InitializeSUP (string username, string password, string SAPID);
}
I added the lib_POD_SUP_MBO.a library as directed in the doc and Xamarin did create the *.linkwith.cs file.
I added a reference to my main project for this library and call the above method in my .net code.
No errors or warnings when compiling, linking and running (in Simulator and on a real device).
The problem is, nothing happens. I even threw logging statements in this method and watched the console on both the device and simulator, nothing. The call just goes into a black hole.
I then tried to write another simple method that does nothing but return a literal integer:
.h:
+ (int) GetValue : (NSString *)dummy;
.m:
+(int) GetValue : (NSString *)dummy
{
return 444;
}
ApiDefinition.cs altered to:
[BaseType (typeof (NSObject))]
public partial interface PODSUP
{
[Static, Export ("InitializeSUP:password:SAPID:")]
void InitializeSUP (string username, string password, string SAPID);
[Static, Export ("GetValue:")]
int GetValue (string dummy);
}
I call the GetValue in my code and assign the value to an int, I get a zero back every time.
Can anyone point out what I might be doing wrong?
Thanks much!