Recent

Author Topic: Compatibility of your apps with specific Mac versions  (Read 12729 times)

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Compatibility of your apps with specific Mac versions
« on: March 18, 2012, 06:32:36 pm »
Hello, is it true that if you develop your applications with Lazarus under Mac, they will only be compatible with the version of the Mac OS you are using or higher?

Is there any way you can make your apps compatible with as many Mac versions as possible?

Thanks in advance.
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

Andru

  • Full Member
  • ***
  • Posts: 112
Re: Compatibility of your apps with specific Mac versions
« Reply #1 on: March 18, 2012, 06:51:33 pm »
Quote
is it true that if you develop your applications with Lazarus under Mac, they will only be compatible with the version of the Mac OS you are using or higher?
No, this is not true. Seems you are talking about special linker option(should be added to Project->Options->Compiler Options->Other):
Code: [Select]
-k"-macosx_version_min 10.4"

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Compatibility of your apps with specific Mac versions
« Reply #2 on: March 18, 2012, 07:13:05 pm »

Is there any way you can make your apps compatible with as many Mac versions as possible?


At least 3 things you need to do manually since Lazarus doesn't know how to do them:

(1) Pass -macosx_version_min switch to linker via FPC -k switch.

(2) In your app bundle's Info.plist file, set LSMinimumSystemVersion to this version as well. OS X will then try to display an error message if the app is run on an unsupported version (rather than just crashing the app).

(3) Link against the appropriate SDK via the FPC -XR switch. This ensure that you're only linking against things (libraries, etc.) that actually exist on your target version of  OS X.

The -XR switch sets the linker -syslibroot switch. Note that with Xcode 4.3.x, the SDKs are inside the Xcode.app bundle now, not under /Developer.

Both linker switches are documented here:

https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/ld.1.html

If you're coming from Xcode, -macos_version_min corresponds to the MACOSX_DEPLOYMENT_TARGET build setting. And -syslibroot corresponds to the SDKROOT build setting.

Info.plist is here:

http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html


I would also suggest that you test on all versions of OS X that you plan to support.

Thanks.

-Phil

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #3 on: March 18, 2012, 07:43:22 pm »
Quote
I would also suggest that you test on all versions of OS X that you plan to support.

I would love to but I can't, simply because I only have one iMac.

Question: what happens if I don't pass any parameters to the linker? Would the final user get an error message if his Mac version is lower than mine (OS X 10.7.3)? In other words, if I don't touch that parameter, what is the default behaviour of a Mac application compiled through Lazarus?

Please consider that in my Lazarus application I only use basic code to manage an SQLite database. Yesterday, before installing Lazarus, I downloaded the latest version of Xcode (v. 4.3.1).

Thanks a lot for your help.
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Compatibility of your apps with specific Mac versions
« Reply #4 on: March 18, 2012, 07:59:58 pm »
Usually, the user gets an error message that the application can not run on this machine.

Additional info may be found at http://wiki.lazarus.freepascal.org/OS_X_Programming_Tips#Deploying_an_executable.2C_Compiling_under_10.6_for_10.5_and_above
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Compatibility of your apps with specific Mac versions
« Reply #5 on: March 18, 2012, 08:23:59 pm »

Question: what happens if I don't pass any parameters to the linker? Would the final user get an error message if his Mac version is lower than mine (OS X 10.7.3)? In other words, if I don't touch that parameter, what is the default behaviour of a Mac application compiled through Lazarus?

Please consider that in my Lazarus application I only use basic code to manage an SQLite database. Yesterday, before installing Lazarus, I downloaded the latest version of Xcode (v. 4.3.1).

The linker stores each library's compatibility version in your executable. As long the compatibility versions of all frameworks and libraries that you link against are <= the compatibility versions of your user's version of OS X, the app should at least try to start. Since Lazarus is linked against the 10.4 SDK, that means the LCL "Carbon" interface isn't using newer stuff that won't be on earlier systems. You can see the compatibility info for any library or executable:

otool -L execfile

With Sqlite you're also linking to something that Laz links against (although I'm not sure why). However, the compatibility version of the Sqlite library hasn't changed since at least 10.5, so you should be okay there. Note that Sqlite comes preinstalled on all Macs, but not Windows.

Xcode 4.3.1 includes 10.6 and 10.7 SDKs.

Thanks.

-Phil

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #6 on: March 18, 2012, 09:33:58 pm »
Quote
Since Lazarus is linked against the 10.4 SDK, that means the LCL "Carbon" interface isn't using newer stuff that won't be on earlier systems.

Xcode 4.3.1 includes 10.6 and 10.7 SDKs.

Since I'm using Xcode 4.3.1, which includes 10.6 and 10.7 SDKs, does it mean that, on my Mac, Lazarus is linked to these newer versions of the SDKs and, consequently, I may lose compatibility with older versions of OS X?
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #8 on: March 18, 2012, 10:03:31 pm »
I'm very sorry, but I don't know how to get to

Quote
Project->Options->Compiler Options->Other

I thought you were talking about Lazarus' settings but then I realized that those items are not present under the project options.

Consider that, so far, I have never used Xcode directly. The only development environment I'm using is Lazarus.

So, where should I go exactly to set the macosx_version_min equal to 10.4?

Thanks.
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Compatibility of your apps with specific Mac versions
« Reply #9 on: March 18, 2012, 10:14:10 pm »
I thought you were talking about Lazarus' settings but then I realized that those items are not present under the project options.

In fact they are available in Lazarus. Please klick the menu "Project" and select the entry "Project Options...". Then a dialog box is presented, there please select the group "Compiler Options" in the frame on the left hand side. Here, the entry "other" allows to enter custom options.

See the attached screenshot for reference.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #10 on: March 18, 2012, 10:39:48 pm »
Thanks. I couldn't find it because the Italian translation of the Lazarus IDE I have is quite misleading.

I copied the exact lines you wrote in the screenshot but it prevents the app from being compiled. Does it depend on the path of the Developer folder which is indicated?

Do you know how I can get the equivalent path on my Mac?
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #11 on: March 19, 2012, 08:56:44 pm »
Quote
Link against the appropriate SDK via the FPC -XR switch. This ensure that you're only linking against things (libraries, etc.) that actually exist on your target version of  OS X.

The -XR switch sets the linker -syslibroot switch. Note that with Xcode 4.3.x, the SDKs are inside the Xcode.app bundle now, not under /Developer.

As the path to the SDKs has changed, I suppose the following lines should be changed as well:

Code: [Select]
-k-macosx_version_min -k10.5
-XR/Developer/SDKs/MacOSX10.5.sdk

So, what should we write instead?
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #12 on: March 22, 2012, 08:43:00 pm »
Xcode contains a subfolder called "Developer" but, within that subfolder, there's no further subfolder called "SDKs".

What am I missing?
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Compatibility of your apps with specific Mac versions
« Reply #13 on: March 22, 2012, 10:48:58 pm »
The SDKs should be in /Developer/SDKs/ .
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

pasquale

  • Sr. Member
  • ****
  • Posts: 267
    • Esposito Software
Re: Compatibility of your apps with specific Mac versions
« Reply #14 on: March 22, 2012, 10:54:26 pm »
Hi, I have just found the new SDK path under Xcode 4.3.1. This is the code I have used in Lazarus:

Code: [Select]

-k-macosx_version_min -k10.6
-XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk


Now I receive no error message when I compile my application.

Unfortunately, I have found out that the version of Xcode I am using can only compile against MacOSX10.6.sdk or MacOSX10.7.sdk

Is there any way I can install the SDK for MacOSX10.5.sdk?

Thanks in advance.
« Last Edit: March 22, 2012, 10:58:35 pm by pasquale »
Apple loves breaking backward compatibility to make money. If you want to be sure that your apps will never stop working, use Windows and trash macOS!

 

TinyPortal © 2005-2018