Lazarus 1.8.0 RC3
macOS 10.12.5
I think I've found out all of the environment variables I need. On a default set of installations on the Apple Mac, they are:
PP=/usr/local/bin/fpc
FPCDIR=/usr/local/share/fpcsrc
LAZARUSDIR=/Developer/lazarus
FPCTARGET=i386-darwin
FPCTARGETCPU=i386
If anyone is doing CodeTools stuff on an Apple Mac under Sierra and wants to debug then use the guide on this page to set up Xcode.
https://macpgmr.github.io/ObjP/ProjectXC.htmlThere are a few things to remember. Try to put your code that you want debugged in a class in a
.pas file and call that class from a console app. Xcode debugging doesn't seem to work directly in
.lpr files.
You'll need to add the environment variables to Xcode. Select
Product -> Scheme -> Edit Scheme and add the environment variables here along with any runtime parameters, such as a
.pas file parameter. See the attached image as a guide.
Have a look at the end of this thread for some hopefully solved issues about project name case.
https://forum.lazarus.freepascal.org/index.php/topic,37588.0.html Using this setup I have managed to debug in Xcode to the end of this method without raising any exceptions. I just need to figure out how the
CodeToolBoss.Explore(Code, CodeTool, True, True); stuff works next. But that can wait until the morning!
procedure TcaMethodGroup.RunMethodGroup;
var
Code: TCodeBuffer;
FileName: string;
CodeTool: TCodeTool;
begin
FileName := ParamStr(1);
try
CodeToolBoss.SimpleInit(ConfigFilename);
writeln('passed simple init');
Code := CodeToolBoss.LoadFile(FileName, False, False);
if Code = nil then
raise Exception.Create('loading failed ' + FileName);
writeln('passed Code nil check');
writeln('FPCDIR=' + GetEnvironmentVariableUtf8('FPCDIR'));
writeln('FPCTARGET=' + GetEnvironmentVariableUtf8('FPCTARGET'));
writeln('passed env variables');
CodeToolBoss.Explore(Code, CodeTool, True, True);
except
on E: Exception do
writeln('Exception: ' + E.Message);
end;
end;
I'm quite tired I may have missed some important details out. Just ask if necessary.
Cheers,
Carl