Hi,
I hope someone can help. I am following the guide here xojo blog loading 3rd party frameworks in xojo ios to add a custom framework to my iOS project.
I have built a framework for iOS with the following in the PenIOS.h file
[code]+ (PenIOS *)sharedInstance;
- (NSInteger) Test_Int;
- (NSString *) FunctionOneString;[/code]
And in the PenIOS.m file
[code]- (NSInteger) Test_Int
{
return 22;
}
- (NSString *) FunctionOneString
{
NSLog(@“Returning: Test String”);
return @“Test String”;
}
- (PenIOS *)sharedInstance
{
static dispatch_once_t predicate = 0;
__strong static id sharedObject = nil;
dispatch_once(&predicate, ^{ sharedObject = [[self alloc] init]; });
return sharedObject;
}[/code]
PenIOS is an NSObject with a sharedInstance as in the framework used on the blog.
I built the framework and added it to a copy files build phase placed between the Build and Sign phases.
I then added the following to a button but num is always 0 and Label1.Text gets set to blank when clicking the button.
[code]Declare Function dlopen Lib “/usr/lib/libSystem.dylib” (name As CString, flags As Int32) As Ptr
Call dlopen("@executable_path/Penios.framework/Penios", 1 Or 8)
// NOTE: We’re specifically NOT using the actual lib name here.
// This is just to satisfy the Xojo linker. The correct framework will be used at runtime.
Declare Function NSClassFromString Lib “Foundation” (clsName As CFStringRef) As Ptr
Dim pbclass As Ptr = NSClassFromString(“PenIOS”)
Declare Function sharedInstance Lib “Foundation” Selector “sharedInstance” (clsref As Ptr) As Ptr
Dim pbclassShared as Ptr = sharedInstance(pbclass)
Declare Function FunctionOneStr lib “Foundation” Selector “FunctionOneString” (obj as ptr) As CFStringRef
Declare Function Test_Int lib “Foundation” Selector “Test_Int” (obj as ptr) As Integer
Dim num As Integer = Test_Int(pbclassShared)
Label1.Text = FunctionOneStr(pbclassShared)[/code]
Any help would be appreciated.
Thanks in advance