macOS Frameworks

From Lazarus wiki
Revision as of 08:27, 15 February 2021 by Skalogryz (talk | contribs) (Created page with "'''todo: please write a better description of what the framework is''' macOS provides a unique way for distributing dynamic libraries: Frameworks. Frameworks are actually a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

todo: please write a better description of what the framework is

macOS provides a unique way for distributing dynamic libraries: Frameworks.

Frameworks are actually a set of dynamic libraries and corresponding resources to them. A special kind of Frameworks are system Plugins (or drivers).

All macOS system APIs come in the form of a framework.

Many third-party libraries come in a form of Frameworks for macOS (i.e. SDL), while providing an option to be loaded as a regular dynamic library

Linking a Framework

The framework can be linked either via a source code:

  {$linkframework SDL2}

or via a linker instructions. (for FPC each parameter should be prefixed with "-k")

-framework SDL2

Note that frameworks exist in macOS only, thus the instructions should be carefully isolated from other systems (as might producer compile time or link time errors)

If the linker results in the error, such as "framework cannot be found". The search path for the framework must be specified (using linker "-F" parameter):

-F /Library/Frameworks

Note:

  • the linker search path will be set to the current system-wide SDK used, as configured by Xcode command-line tools.
  • the third party Frameworks should either be installed, or the path should be explicitly specified via -F parameter.

Distributing Application with a Framework

See Also

macOS Dynamic Libraries