When a new version of Xcode comes out, invariably there is only one SDK for iOS and macOS included. As is Apple’s way, sometimes they change something in the new SDK that breaks the SDK import in Delphi. This article describes a couple of solutions for it.

The problem

The typical scenario is: you start a completely new install of Delphi, either because you’re a new user, or you like to start a new installation with a new version. You install Xcode on the Mac (or already have), and you go to import the SDK in Delphi, using Tools|Options, Deployment > SDK Manager.

At the time of writing, the latest released version of Xcode is 11.6. In Delphi’s SDK Manager you go to import the iOS SDK, and the only SDK available is iOS 13.6. You select that, import the SDK, then attempt to compile an iOS application. Unfortunately you are greeted with:

ld: file not found: /usr/lib/system/libcache.dylib for architecture arm64
[DCC Fatal Error] F2588 Linker error code: 1 ($00000001)

This is because Apple have changed what is distributed with the iOS 13.6 SDK. In the SDK folder (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.SDK). The /usr/lib/system folder underneath simply does not exist. (I will update later as to why this is, since I am yet to find out).

So what can you do about this? If you have access to an installation of Delphi where the iOS 13.x SDK (preferably iOS 13.5) had been imported, the solution may be relatively trivial.

Solution 1

By default, SDKs are imported into C:\Users\[username]\Documents\Embarcadero\Studio\SDKs (where [username] is the login name for that computer.) You could:

  • Copy the iPhoneOS13.5.sdk folder from the SDKs folder on wherever the other Delphi installation is, to corresponding folder of the machine of your new installation
  • Export the HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\PlatformSDKs\iPhoneOS13.5.sdk (21.0 = Delphi 10.4) registry key from that machine, and import it into the registry of the new installation

Solution 2

Only if you’re unable to use Solution 1 (hint: another developer may be able to help you out), you may consider downloading an older version of Xcode so that you can obtain the older SDK. Older versions of Xcode can be downloaded from here. (you may need to sign in). You could:

  • Download Xcode 11.5, and extract it somewhere on your Mac, other than in the Applications folder where the current version is.
  • Open a Terminal window on the Mac (/Applications/Utilities/Terminal), and enter the following:
    sudo xcode-select -s [path]/Xcode.app

    Where [path] is the path where you extracted the older version to.

  • In Delphi, you should now be able to import the iOS 13.5 SDK. Once you have, you can execute the following command to switch Xcode back to the default:
    sudo xcode-select -r

    Alternatively, you could not execute this command and work with Xcode 11.5 being active for as long as is practicable.

macOS SDKs

The above solutions may well work similarly for macOS SDKs if you’re stuck in the same situation.