Sign in Join
Wiki copytemporary

FPC 2.6.1 macOS Targets: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: FPC 2.6.1 macOS Targets

OldNewLine
1+## FPC 2.6.1 and below
2+
3+To make sure that an application will run under previous macOS releases, use the *-macosx_version_min* linker parameter and link against the appropriate SDK (e.g. -XR/Developer/SDKs/MacOSX10.5.sdk/ or -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/). For example, to compile an application that should work on Leopard 10.5 and higher:
4+
5+Add to /etc/fpc.cfg OR to Project / Compiler options / Other / Custom options:
6+
7+ -k-macosx_version_min -k10.5
8+ -XR/Developer/SDKs/MacOSX10.5.sdk/
9+
10+The 10.4 SDK is the only one with a special name (10.4u instead of 10.4). Other SDK names simply contain the major macOS version number: MacOSX10.5.sdk, MacOSX10.6.sdk, ...
11+
12+Note: The path */Developer* depends on where you installed the Apple developer tools, and may be different if you chose a different location. Do not assume it will always be /Developer.
13+
14+The 10.7 is by default:
15+
16+ -k-macosx_version_min -k10.7
17+ -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/
18+
19+For targeting Tiger 10.4 the following settings are required:
20+
21+ -k-macosx_version_min -k10.4
22+ -XR/Developer/SDKs/MacOSX10.4u.sdk/
23+
24+### Adding the custom options only when compiling for macOS
25+
26+To add the above custom options only when compiling for macOS add to Project / Compiler options / IDE macros / Conditionals:
27+
28+``` pascal
29+if TargetOS = 'darwin' then begin
30+ UsageCustomOptions += ' -k-macosx_version_min -k10.5';
31+ UsageCustomOptions += ' -XR/Developer/SDKs/MacOSX10.5.sdk/';
32+end;
33+```
34+
35+---
36+*From the Free Pascal wiki, page "FPC 2.6.1 macOS Targets", as it stood on 2022-03-15 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history