-
Notifications
You must be signed in to change notification settings - Fork 52
macOS
Whenever Lazarus creates an OSX bundle, it puts a symbolic link to an executable into the bundle.
prog
prog.app
Contents
MacOS
prog --> ../../../prog
However CEF expects an actual executable binary instead of a symbolic link, otherwise the bundle detection fails and the library complains about missing files and resources. The debug version then outputs the following error:
[1214/225716:FATAL:bundle_locations.mm(62)] Check failed: new_bundle. Failed to load the bundle at Contents/Frameworks/Chromium Embedded Framework.framework
Therefore the LCLSimple
and SubProcess
examples use an Execute after command (see fpc wiki) to copy the binary into the right place after compilation.
Please note: The single-process mode in CEF is very much unmaintained and not tested very well. It is strongly recommended to use the default multi-process mode instead.
-
open the
LCLSimple
project, available in theExamples
directory of fpCEF3 -
switch to
macOS
build mode (howto) -
modify
TMainform.FormCreate
method as follows:procedure TMainform.FormCreate(Sender: TObject); begin {$IFDEF DARWIN} CefSingleProcess:=true; {$ELSE} CefBrowserSubprocessPath := '.' + PathDelim + 'subprocess'{$IFDEF WINDOWS}+'.exe'{$ENDIF}; {$ENDIF} end;
This will enable single process mode and an external sub process will not be needed.
-
open the
simple.app
bundle either by using the command line (andcd
into the bundle) or using Finder (right-click and selectShow Package Content
) -
copy the
Chromium Embedded Framework
framework into the directoryContents/Frameworks
-
compile and run the application
For a multiprocess application additionally a subprocess application is needed. For LCLSimple
the unmodified default CEF subprocess application in Examples/SubProcess
can be used.
-
open the
SubProcess
project, available in theExamples
directory of fpCEF3 -
switch to
macOS
build mode (howto) -
compile the project
-
open the
LCLSimple
project, available in theExamples
directory of fpCEF3 -
switch to
macOS
build mode (howto) -
modify
TMainform.FormCreate
method as follows:procedure TMainform.FormCreate(Sender: TObject); begin {$IFDEF DARWIN} CefBrowserSubprocessPath := ExtractFileDir(ExtractFileDir(ExpandFileName(Paramstr(0)))) +PathDelim+'Frameworks/subprocess.app/Contents/MacOS/subprocess'; ; {$ELSE} CefBrowserSubprocessPath := '.' + PathDelim + 'subprocess'{$IFDEF WINDOWS}+'.exe'{$ENDIF}; {$ENDIF} end;
-
open the
simple.app
bundle either by using the command line (andcd
into the bundle) or using Finder (right-click and selectShow Package Content
) -
copy the
Chromium Embedded Framework
framework into the directoryContents/Frameworks
-
copy the
subprocess.app
into the same directory -
compile and run the application
-
make sure to set the target OS to
Darwin
and the target CPU tox86_64
-
Lazarus can be used to create the application bundle, however don't forget to replace the symbolic link inside the bundle with the actual binary as described here
For the subprocess bundle one additional steps are needed:
- open the file
Info.plist
e.g. with Xcode - add the parameter
Application is agent (UIElement)
- open the file
-
CEF expects the subprocess application bundle and executable to be named
<APPNAME> Helper
. For theLCLSimple
example the name would besimple Helper
. If this bundle is not found inside theFrameworks
folder, CEF will create it automatically.If the subprocess does not follow this naming rule,
CefBrowserSubProcess
must be set to the path of the subprocess executable (like in the description above).However it is recommended to follow the naming convention (unlike the description above). In this case
CefBrowserSubProcess
is not needed.Don't forget to change the
CFBundleExecutable
key in theInfo.plist
file if you rename the executable.