Deploying to iOS

Deploying apps from Delphi to an iOS device requires a Mac computer. As compared to Android, deploying to iOS requires more steps because you also need to enroll for the Apple iOS Developer Program and to provision the device you want to deploy to.

First, you need to make sure that the iOS device that you want to deploy your application to is compatible. In case of iPhone, the oldest supported model is 4GS, but you want to have a device that can have iOS 10 installed. In my case, it is iPhone 6S.

The first steps to prepare your Mac and an iOS device for deployment are exactly the same that any iOS developer needs to do. This is something that you do once. During the process of deploying to an iOS device, an app needs to be digitally signed with the special command-line tool that comes with Apple Xcode installation. You could install just the Xcode command-line tools, but in practice it is easier to install the whole Xcode development environment from Apple.

In order to be able to deploy apps to an iOS device, it needs to be provisioned first. The process of provisioning iOS devices, joining the Apple iOS Developer Program, and installing various certificates is the same as in the case of any app developed with Xcode. In order to be sure that you will be able to deploy an app from Delphi into iOS, it is recommended to create an empty app from a template in Xcode and try to run it on the device. If this is successful, the next step is to install a special PAServer Mac program on the machine where you have Xcode installed. The PAServer19.0.pkg installable package is installed in the PAServer subdirectory of Delphi. Just copy it over to your Mac and execute. This will install the PAServer. The PAServer is implemented as a command-line app, and after it is launched on Mac, it will display a command-line interface where you will be prompted to enter your Mac password. Your Mac will also display a dialog asking if it is OK to give PAServer debugging permissions. Accept it.

You can think about the PAServer as an agent that performs operations on behalf of the Delphi IDE that runs on a remote Windows machine. In order for Delphi to be able to connect, you need to know the IP address of the machine where the PAServer is running. You can find out the IP address by issuing the i command from the PAServer's Command Prompt. The list of all available command-line parameters to PAServer is displayed when you enter ? in the Command Prompt, as shown in the following screenshot:

PAServer running on Mac

Now we need to configure Delphi, so it can find the iOS device you want to deploy to. The goal is to find your device listed in the Project Manager. In general, you could have multiple different Macs visible to your Delphi installation. For every Mac you want to deploy to, you need to define a connection profile.

Make sure that our DelphiHelloWorld project is open in the IDE.

Double-click on the iOS Device - 64 bit node under Target to make it active. It will be displayed in bold. Now, right-click on the node and select Properties. You will see a small Platform Properties dialog where you will be able to select the proper iOS SDK. Click on the SDK combo box and select Add New... from the dropdown.

Then, select Add New from the connection profile combo. The Create a Connection Profile wizard will be displayed. I have entered DelphiDev as the profile name. Click on Next. On the next tab of the wizard dialog, we need to enter the address and port of the remote machine. Keep the default port 64211 and enter your Mac password in the last field. Now click on the Test Connection button to verify that the IDE can communicate with the remote PAServer. If everything went well you should see the message that the connection to your Mac succeeded. Click on Finish, as shown in the following screenshot:

"Create a Connection Profile" dialog

Now, back in the Add a New SDK dialog, select the SDK version to add and click on OK:

Add a New SDK dialog

This will initiate the process of updating the local file cache, with files being downloaded from Mac that are needed by the Delphi iOS compiler to generate an iOS executable file. Refer to the following screenshot:

Updating Local Cache

After the cache is refreshed, the IDE should automatically update the iOS 64-bit Target node and you should see your device listed there:

Project Manager with an iPhone device listed as a target

Now click on the Run button. This will locally build the iOS ipa executable file and send it to the Mac machine where PAServer is running. The PAServer will invoke the command-line tool from the Xcode installation to digitally sign the executable, and then it will be deployed and run on the physical iOS device--all in one operation.

And here is how our Delphi Hello World app looks on my iPhone 6 running iOS 10:

Delphi "Hello World" app running on iOS

More information about deploying apps to iOS devices from Delphi can be found online at http://docwiki.embarcadero.com/RADStudio/en/IOS_Mobile_Application_Development.