Fix: iOS 17 / XCode 15 for Delphi 11.3

Fix: iOS 17 / XCode 15 for Delphi 11.3

Solving deployment issues with Delphi for iOS

Two recent issues have risen once XCode has been updated to 15.0.1 while using Delphi 11.3 to update your mobile application. There are two fixes to add to support iOS 17 and the changes for XCode after updating: (1) updating your SDK on XCode, since the update removes the iOS Simulator and SDK; and (2) patching the RootViewController initialization of the WindowManager for the PlatformCocoaTouch on iOS.

First, we are going to make sure you have the iOS SDK installed for Mobile development. We will do so by following the next steps:

  1. Run XCode

  2. Go to XCode > Settings...

  3. Select the Platforms tab

  4. If the iOS 17.0 entry is missing showing a GET button, click on the GET button! Otherwise, if it shows in blue icon as the screen shot below, then you have it set up accordingly.

Once the steps are followed you should be all set.

Last, we are going to patch the file in FMX.Platform.iOS.pas. Go to the following folder "C:\Program Files (x86)\Embarcadero\Studio\22.0\source\fmx", this is the default installation folder for your Embarcadero, RAD IDE as shown in the image below.

Next, copy the file to your local projects folder, and add it to your project. Go to line 1526, and modify the following section:

    // Creating window
    WindowManager := PlatformCocoaTouch.WindowManager;
    WindowManager.Window := TFMXWindow.Create(MainScreen.bounds);
    WindowManager.RootViewController := TFMXViewController.Create;
    WindowManager.NativeWindow.makeKeyAndVisible;

To the following for the iOS fix.

    // Creating window
    WindowManager := PlatformCocoaTouch.WindowManager;
    WindowManager.Window := TFMXWindow.Create(MainScreen.bounds);
    WindowManager.RootViewController := TFMXViewController.Create;
    // *** Start of iOS17 SDK crash issue - Add the following line: ***
    WindowManager.RootViewController.Super.init;
    // *** End of iOS17 SDK crash issue ***        
    WindowManager.NativeWindow.makeKeyAndVisible;

These simple fixes should allow you to address the issues for cross-compiling and building your application for iOS after updating to the latest version of XCode, in this case, 15.0.1.

References

https://www.reddit.com/r/delphi/comments/16r7l68/delphi_app_crashing_on_device_running_ios_17/

Did you find this article valuable?

Support Alessandro by becoming a sponsor. Any amount is appreciated!