If you want to import the Objective-C class, you must do the following:
type //here you define the class with it non static Methods objc_test = interface (NSObject) [InterfaceGUID] function test(value : integer) : integer; cdecl; end; type //here you define static class Methods objc_testClass = interface(NSObjectClass) [InterfaceGUID] end; type //the TOCGenericImport maps objC Classes to Delphi Interfaces when you call Create of TObjc_TestClass TObjc_TestClass = class(TOCGenericImport<objc_testClass, objc_Test>) end;
Also, you need a dlopen('test.a', RTLD_LAZY) (dlopen determined Posix.Dlfcn)
Then you can use the code as follows:
procedure Test; var testClass: objc_test; begin testClass := TObjc_TestClass.Create; testClass.test(3); end;
source share