Hi guys, I'm pulling my hair with an error in a desktop app in osx. Using FPC 3.0.4, lazarus 2.0.4
I'm trying to allow my app to respond to a custom URL protocol and used this code from
https://raw.githubusercontent.com/transmission-remote-gui/transgui/master/urllistenerosx.pasunit URLListenerOSX;
{$mode objfpc}{$H+}
{$modeswitch objectivec2}
interface
uses
Classes, SysUtils, CocoaAll, InternetConfig, AppleEvents;
type
THandlerProc = procedure(const url: string);
{ TAppURLHandler }
TAppURLHandler = objcclass(NSObject)
public
procedure getUrlwithReplyEvent(event: NSAppleEventDescriptor; eventReply: NSAppleEventDescriptor); message 'getUrl:withReplyEvent:';
public
callBack: THandlerProc;
end;
procedure RegisterURLHandler(HandlerProc: THandlerProc);
var
handler : TAppURLHandler;
eventManager: NSAppleEventManager;
implementation
{ TAppURLHandler }
procedure TAppURLHandler.getUrlwithReplyEvent(event: NSAppleEventDescriptor; eventReply: NSAppleEventDescriptor);
var
url : NSString;
begin
url:=event.paramDescriptorForKeyword(keyDirectObject).stringValue;
callBack(url.UTF8String);
end;
procedure RegisterURLHandler(HandlerProc: THandlerProc);
begin
handler:=TAppURLHandler.alloc.init;
handler.callBack:=HandlerProc;
eventManager:=NSAppleEventManager.sharedAppleEventManager;
eventManager.setEventHandler_andSelector_forEventClass_andEventID(handler,ObjCSelector(handler.getUrlwithReplyEvent), kInternetEventClass,kAEGetURL);
end;
end.
In the FormCreate event of the main form, I call the code above with the line
RegisterURLHandler(@HandleMyCustomURLProtocol);
and this is the only line
The project fails to compile with the error
Error: linker: Undefined symbols for architecture i386:
Error: linker: "_res_9_ninit", referenced from:
An error occurred while linking
myapp.lpr(24,1) Error: Error while linkingIf I remove the line in FormCreate the project compilation succeeds
Anyone knows why it's not working? Where can I find more details about the error? Thanks in advance!!!