Movatterモバイル変換


[0]ホーム

URL:


Packt
Search iconClose icon
Search icon CANCEL
Subscription
0
Cart icon
Your Cart(0 item)
Close icon
You have no products in your basket yet
Save more on your purchases!discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Profile icon
Account
Close icon

Change country

Modal Close icon
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timerSALE ENDS IN
0Days
:
00Hours
:
00Minutes
:
00Seconds
Home> Programming> Programming Language> Expert Delphi
Expert Delphi
Expert Delphi

Expert Delphi: Robust and fast cross-platform application development

Arrow left icon
Profile Icon Paweł Głowacki
Arrow right icon
S$53.98S$59.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.6(5 Ratings)
eBookJun 2017506 pages1st Edition
eBook
S$53.98 S$59.99
Paperback
S$74.99
Subscription
Free Trial
Arrow left icon
Profile Icon Paweł Głowacki
Arrow right icon
S$53.98S$59.99
Full star iconFull star iconFull star iconFull star iconHalf star icon4.6(5 Ratings)
eBookJun 2017506 pages1st Edition
eBook
S$53.98 S$59.99
Paperback
S$74.99
Subscription
Free Trial
eBook
S$53.98 S$59.99
Paperback
S$74.99
Subscription
Free Trial

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
OR

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Table of content iconView table of contentsPreview book icon Preview Book

Expert Delphi

Fasten Your Seat Belts

The key benefit of Delphi in mobile development is that you can design your app once and, from the same source code, you can natively compile it for both Android and iOS. This chapter is exactly about this capability. We are going to first install Delphi, create a simple one-button "Hello World" app, and then run the same app on Google Nexus 7 and on Apple iPhone 6S.

TheIntegrated Development Environment (IDE) is where the programmer spends the most of the time. Learning best practices of using the IDE will pay off in the future and will increase your developer productivity. Before going into building apps, you need to feel comfortable working in the IDE.

The objective of this chapter is to install the Delphi IDE, learn basic IDE functionality, and prepare it for mobile development.

Delphi installation

Delphi is a Windows program, so you need to have a computer with a proper version of Windows installed and enough free space on your hard drive. You may want to install Delphi on a physical computer or onto a Windows virtual machine image using one of the available virtualization solutions such as VMware. Installing onto a virtual machine has some advantages in cross-platform development. In order to create iOS apps, you will need to have access to a Mac computer. This could be another computer available on a local network or the same physical machine. One of the most convenient configurations is to have just one physical machine that allows you to target all operating system platforms supported by Delphi.

In order to deploy to iOS devices, you need to use a physical Mac machine. At the same time, Delphi is a Windows program, so you will also need Windows. You can use both on one computer by running Windows in a virtual machine installed on Mac. Whether you choose to install Delphi onto a physical or virtual Windows machine, the installation process is the same.

Delphi is implemented as a native Windows 32-bit executable. As such, it can be installed to either 32-bit or 64-bit versions of Windows. Some parts of Delphi are written in .NET 3.5, so at the beginning of the installation, the installer may also install a .NET 3.5 redistributable package which is not installed by default in newer versions of Windows.

Delphi versions

Delphi comes in different versions, so before downloading the installer, we need to decide which version to choose. There are four Delphi versions--Starter, Professional, Enterprise, and Architect:

  • TheStarter version is the simplest one and it does not contain features necessary for doing mobile development. This version is aimed at hobbyists, students, and in general for anyone that just wants to learn Delphi.Starter supports building application for Windows 32-bit only. That's not what we need.
  • The next version isProfessional. It also does not contain features for mobile development, but they can be installed separately in the form ofmobile add-on packs. TheProfessional is a good choice if you plan to build applications for Windows and you do not need the possibility to connect to remote databases.
  • The third version isEnterprise. This is the full version of Delphi and contains everything that is in theProfessional plus more. It allows you to create apps for all supported mobile and desktop platforms including Android, iOS, Windows, Mac, and Linux. It also contains theDataSnap framework for building scalable, multitier systems that is not available in Professional edition. This is the version of Delphi that we are going to use in this book.
  • The highest Delphi version isArchitect. This is a product bundle that contains DelphiEnterprise and separately installedER/Studio Developer Edition for modeling relational SQL databases andDB Power Studio Developer Edition that contains tools for working with SQL databases.

Delphi is available as a standalone product, but it can also be used as part of RAD Studio. RAD Studio contains Delphi and C++Builder. Delphi and C++Builder are two differentIDE personalities of RAD Studio and both can be installed from the same RAD Studio installer into one deeply integrated environment. Both products, Delphi and C++Builder, provide the same capabilities of building mobile and desktop apps for different operating systems from the same source code using visual designers, and share the same component libraries, but differ in the programming language being used. Delphi uses Object Pascal and C++Builder uses standard C++.

I'm trying as much as possible to make sure that this book is not tied to any particular Delphi version. However, it is important to pay attention to which version of different pieces of software we are using.

In this book, we are going to use Delphi 10.2Tokyo Enterprise edition. Delphi is produced by Embarcadero and you can find more information about different Delphi versions and features on the Embarcadero Delphi home page (http://www.embarcadero.com/products/delphi). You can get Delphi directly through the Embarcadero website or through one of many partner companies that represent Embarcadero in different countries. After purchasing Delphi, you will receive an automatically generated email with the download link to the Delphi installer and the serial number that you will need during the installation.

Running the Delphi installer

Delphi installer is available in two different formats. You can either choose to install Delphi using the so-calledElectronic Software Delivery (ESD) for short, or you can install from the ISO image of the full Delphi installation DVD. The first option is the default one and it makes for faster installation. The ESD installer is a relatively small application that downloads and installs only those parts of Delphi that you have chosen at the beginning of the installation process. After Delphi is installed you can always choose to install or uninstall different features. The second option is to install from the DVD ISO image. This is useful when the internet access is slow, unreliable, or for some security reasons the Windows machine that you install Delphi onto does not have internet access at all.

Here we are going to use the web installer. Download the installation file from the link provided in the email. You will need to have administration rights on Windows to be able to install Delphi. On one of the first installer screens you will be prompted to enter the serial number that you have received from Embarcadero and also you will need to enter yourEmbarcadero Developer Network (EDN) username and password. If you do not have an EDN account, you can quickly create one from within the installer. It is free and it makes the connection between the serial number that you have received and you as the user of the software.

During the installation, you can choose which platforms and additional features you want to install. You can always add or remove platforms and features from the IDEWelcome Page after the installation is complete, as shown in the following screenshot:

Platform Selection

After this, we need to select platforms and all additional features, as shown in the following screenshot:

Additional Options

I'm going for the full install, so I have selected all platforms and all additional features to be installed, except for languages other than English. Depending on the speed of your internet connection, the installer should complete the installation in a couple of minutes. At the end of the installation, you will see the message that the installation is complete and you can start working.

If you run into problems during the installation, you can review the DelphiInstallation Notes on the Embarcadero DocWiki (http://docwiki.embarcadero.com/RADStudio/en/Installation_Notes).

Delphi is now installed. Run it and the first thing you will see is theWelcome Page, as shown in the following screenshot:

Delphi Welcome Page

Here you can display thePlatforms and Extensions Manager, which will give you an opportunity to add or remove installed platforms and additional options. From theWelcome Page you can open sample projects, watch video tutorials, and access online documentation. You can also easily open recently closed projects. The projects that you frequently work with can be added toFavorites for quick access.

Installing custom components

Delphi IDE has an open architecture and provides many ways to extend its functionality through additional packages. You can see the list of currently installed packages in theInstalled Packages option available from theComponent menu. The most typical Delphi building block is aComponent. Technically, this is about taking the object-oriented programming principles and moving it one step further. With components, you have the ability to manipulate regular programming language object instances during the design time, before the project is built for a given platform. Packages may also contain custom property editors and theOpen Tools API extension to the IDE itself that may add custom functionality to the IDE, such as additional menus and windows.

Out of the box, with the default Delphi installation, you will get a few hundred components already preinstalled. Depending on your Delphi version and selected features, this list may differ. Click on theInstalled Packages option in theComponent menu to verify which components are actually installed, as shown in the following screenshot:

Installed Packages window with components shown for a selected package

There are many additional free and commercial component packages that are not installed by default. They can be installed with the integratedGetIt Package Manager. It is available either from theWelcome Page or from theTools menu, as shown in the following screenshot:

Delphi GetIt Package Manager

If you want to install any of the available component packages, just click on theInstall button under the image of the package. The installation process is very straightforward. After accepting the license, the components are downloaded from the internet, compiled, and installed into the IDE.

IDE options

You can manage all aspects of how the Delphi IDE works from theOptions dialog available from theTools menu. Here, you can control various aspects of how Delphi operates as a whole. Take a look at the following screenshot:

Delphi Options

Riding the Integrated Development Environment

In a nutshell, Delphi is a program for making other programs. The actual program responsible for generating executable files from the source code is a compiler. It is typically implemented as a command-line application. When executing a command-line application, you can pass to it command-line parameters. Compilers take different command-line parameters, including the location of source code files necessary to generate the resulting binary file. Take a look at the following diagram:

Simplified compiler architecture

It is possible to write your programs using a text editor like Notepad and then execute the compiler from the command line, but it is not the most efficient way of creating applications. Most programmers use IDE for working on apps. The idea of an integrated development environment originates from the Delphi ancestor,Borland Turbo Pascal, and comes from the integration of three previously separate programs: Code Editor, compiler, and debugger.

Delphi compilers and toolchains

Delphi IDE contains different compilers for generating apps for different platforms. The IDE manages all necessary source code files needed for building an app. It also takes care of passing correct parameters to right compilers and manages their output. In the IDE, it is possible to build, deploy, and run an app directly on the mobile device connected with a USB cable by just pressing theRun button. Obviously, it is also possible to generate an executable application without running it. Sometimes it is very handy to be able to step into an application as it is executed in the host operating system. This process is called debugging. In the Delphi IDE, you can run your programwith orwithout debugging.

There are in total eight different Delphi compilers installed with the Delphi 10.2 version:

Delphi compiler

Executable format

dcccaarm.exe

Android

dcciosarm.exe

32-bit iOS

dcciosarm64.exe

64-bit iOS

dcc32.exe

32-bit Windows

dcc64.exe

64-bit Windows

dccosx.exe

32-bit Mac OS X

dccios32.exe

iOS Simulator

dcclinux64.exe

64-bit Linux

These compilers are typically installed into theC:\Program Files (x86)\Embarcadero\Studio\19.0\bin folder. Thebin folder of Delphi has been added to the Windows path by the installer, so you can try and execute them directly.When executed with no parameters, Delphi compilers will just display their version numbers and possible command-line switches, as shown in the following screenshot:

Delphi Android compiler invoked from Command Prompt

Take a look at the following screenshot:

Delphi iOS compiler invoked from Command Prompt

In the IDE, we do not need to invoke command-line compilers directly. The IDE is doing this for us when we choose to either run, build, or compile our project. It will also take care of outputting the resulting binary files into a separate folder per every supported platform and build configuration. When we build, deploy, and run our apps, we can see in the bottom part a log of all commands being executed, parameters passed to them, and their output.

Hello World app

Starting with a new programming language or framework typically involves creating a program that displays the famous "Hello World" message, and we will follow this convention. Our app will have just one button. When you press the button, aDelphi Hello World! message will be displayed. Later in this chapter, we are going to put this app on an iPhone and on an Android device.

Click on theMulti-Device Application - Delphi option in theFile |New menu, as shown in the following screenshot:

New "Multi-Device Application - Delphi" menu option

This will display the wizard with different multi-device project templates, as shown in the following screenshot:

Multi-device application project templates dialog

Double-click on theBlank Application project template.

The first thing after creating a new project is to save it all. The Delphi project is made of multiple files that are managed by the IDE. The IDE will also create subfolders in theproject directory for managing different artifacts such as compiled executable files, editor history, and recovery files, so it is always a good idea to save a new project into an empty directory.

Click on theSave All button in the Delphi toolbar just below the main menu to save all files in the project, as shown in the following screenshot:

The Save All speed-button

Clicking from time to time on theSave All button is something that you do almost automatically.

First, we will be asked to save the main form of our application. EnteruFormHelloWorld in the file save dialog and click onSave. Then, the second file save dialog is displayed. Here we need to give our project a name. EnterDelphiHelloWorld and click onSave.

Delphi organizes all files necessary to build an app into aProject. The Delphi IDE contains a number of windows that help us work on our projects. There are different project types. It is possible to create a project group inside the IDE, but at any given moment of time there can be only one project active. You can see the name of the active Delphi project in the very top left corner of the Delphi window. Its name is also displayed in bold font in theProject Manager. Delphi IDE is context sensitive, so the contents of different windows and dialogs can vary. An example of a context sensitive dialog isProject Options. Select theOptions item from the bottom of theProject menu. All options related to the current project opened in the IDE will be displayed, as shown in the following screenshot:

Project Options Dialog

Let's add a button to the form. The fastest way to work in the IDE is to use theIDE Insight. There are hundreds of different options, components, and windows in the IDE. If you know what you are looking for, you can just pressF6 orCtrl and. keys at the same time. The IDE Insight combobox will receive focus. You can also just click on the IDE Insight combobox in the top corner of the IDE window. We want to add a button to the form. Just start typing what you are looking for and notice how, with every keystroke, the list of available items in the IDE Insight combobox is changing. Typeb,u, andt and, after three keystrokes, theTButton component is the first on the list. Refer to the following screenshot:

Incremental filtering in the IDE Insight combobox

Just pressEnter and a button is added to the form. It is probably one of the single most useful productivity features of the IDE. Six keystrokes are needed to get the component added to the form. Alternatively, we could locate theTButton component in theTool Palette window and double-click it to add it to the form. Over time, you will find that you pressCtrl + almost subconsciously, very much like clicking onSave All. In fact, you can click onSave All right now. :)

We have a button in the middle of an empty form. Let's start working on how our app will look--that's form design. What our app is going to do--that's coding. Click on the button and move it more toward the window's top left corner. In the left bottom part of the IDE there is theObject Inspector window. Here we can modify properties and events of components. We need to change the text that is displayed on the button. Make sure thatTButton1 is selected in theObject Inspector and find itsText property. Replace the defaultButton1 withHello World. Now, find theName property of the button and change it tobtnHelloWorld. Notice that the new name of the component has been immediately reflected in theStructure view above theObject Inspector. Now select the form. You can click somewhere on the form in theForm Designer to select it or just click on the form's node in theStructure view aboveObject Inspector. That's how the IDE works. Different windows are synchronized with each other, so selecting a component, changes the current component selection in other views as well. Find theName property of the main form and change the defaultForm1 toFormHelloWorld. Now, find theCaption property of the form and change it toDelphi Hello World. Save all.

It is always good practice to give components and their properties meaningful names. There are different naming conventions. One of the most popular ones is to give components such name, that, just from the name itself, we could understand what the type of this particular component is. You also want to keep names short. If names are too long, you need to type more. Long names in the source code also tend to be less readable. It is up to you to decide what naming convention you use, but once you have decided, it is important to stick to it.

Now we need to define what will happen when the user of our app clicks on the button. For this, we need to attach an event handler to theOnClick event, of thebtnHelloWorld button. We could switch to theEvents tab in theObject Inspector, locate theOnClick event and double-click on the space next to it to generate an empty event handler. Let's do it faster. Just double-click on the button on the form. The IDE will switch from theForm Designer toCode Editor, and the cursor will be placed just at the beginning of an empty line betweenbegin andend where we need to enter some code in theObject Pascal language. This code will be executed by our app in response to the click event. It could be misleading that this event is calledOnClick, as you can use the mouse on desktop computers only. Fear not! If we compile our app to mobile targets, this event will be triggered in response to touching the button on the mobile device screen. In the code, we will invoke the built-inShowMessage function and pass to itDelphi Hello World! as the string that we want to display in the message.

Click onSave All again. Now let's run the application. Refer to the following screenshot:

Run the current project without debugging

Click on theRun green arrow icon under the main menu to build and run the project. You will get the following output:

Delphi "Hello World" multi-device app running on Windows

We are on Windows and by default, we will compile our multi-device app as a Windows 32-bit executable. This is very useful during the developement of mobile apps with Delphi. During the development it is quicker to run our multi-device app on Windows to see that it does not contain any mistakes. If it compiles fine on Windows, then there is a big chance that it will also compileOK with mobile compilers. Building and deploying to a mobile device typically takes longer.

Every Delphi form is made of two source code files. You can switch between these files by clicking on the third button from the left in the toolbar with the Toggle Form/Unit (F12) hint or at the bottom of the screen using theCode andDesign tabs. When we entereduFormHelloWorld as the name of the main form of our app, the IDE created two files:uFormHelloWorld.pas anduFormHelloWorld.fmx. The first file we can see in theCode tab is the source code, and the following is the screenshot of the toolbar with the toggle button to switch between the files:

Toggle Form/Unit speed button

The Code Editor is where we edit Delphi source files with thepas filename extension. We can see directly the contents of the file in the editor, as shown in the following screenshot:

Delphi Code Editor

The contents of thefmx file are managed by theForm Designer and we do not edit it directly. Every time we change something in theObject Inspector or in theForm Designer, these changes are stored in thefmx file. TheForm Designer gives us awhat you see is what you get user experience, so we can see how our app will look even before we run it. Refer to the following screenshot:

Delphi Form Designer - View as Form

You can preview the text of the form file by right-clicking somewhere on the form and selecting theView As Text option from the context menu.

To return to the form view, just right-click on the editor again and selectView As Form from the context menu, as shown in the following screenshot:

Delphi Form Designer - View as Text

The most important window in the IDE is theProject Manager. It provides a graphical interface to work with all files that make up our projects and lets us switch between different compilers and build configurations. You can build your applications in eitherdebug orrelease mode. The debug mode is used during the development of an app. The resulting binary file will have additional binary information embedded that is used by a debugger. When our app is ready to be built for distributing to an app store, then we can switch to release mode.

This will generate an app in the form that is suitable for distribution. Take a look at the following screenshot:

Delphi Project Manager

Let's have a look at different files that make up a Delphi project. If you want to quickly find the folder where the current project is located, you can do it easily. Click on the name of the project in theProject Manager. In theObject Inspector, you should now see,Full Name andFull Path properties. Copy the content of theFull Path property to the clipboard, paste it into Windows Explorer, and then hitEnter, as shown in the following screenshot:

Current project path and file name in Object Inspector

You should now see all the files and folders that make up ourDelphiHelloWorld project:

Files that make up a Delphi project in Windows 10 File Explorer

Alternatively, you could also right-click on the project name in theProject Manager and select theShow in Explorer option.

Among others, you will see here two files nameduFormHelloWorld and two project files with the same name as our projectDelphiHelloWorld, but with different extensions. The first one has the extensiondpr, which stands forDelphi Project and contains the main program file of our application. We can preview this file inside the IDE by going to theProject |View Source menu, as shown in the following screenshot:

Delphi project source code

It is the application main program file which is managed by the IDE and most of the time, we need to change anything there. The second project file has adproj extension. If we open it in Notepad, we will see that it contains XML code with build instruction, for the MSBuild engine that is used by Delphi to manage all files and resources that are needed to build our project for different targets and configurations, as shown in the following screenshot:

Contents of the dproj project file

There is also awin32 subfolder here. It contains a subfolder calleddebug and two files:DelphiHelloWorld.exe anduFormHelloWorld.dcu. The first file is a regular Windows 32-bit executable program that we have just built. It does very little. It only has a button and displays a message. The second file is the product of compiling a form file and is only useful for the IDE during the build process. You can safely delete thewin32 folder and its contents. The next time you run the application, all folders and files will be recreated. That's where the difference betweenbuilding andcompiling the project comes. The very first time, both commands do exactly the same--they generate all binary files in the output folder. In fact,dcu files are generated first and theexe file is generated next. If we selectBuild every time, all binary files are recreated. If we selectCompile, only thosedcu files are recreated that have changes. This really speeds up running a project inside of the IDE.

Deploying to mobile devices

OurDelphiHelloWorld project is now ready for deployment to mobile devices. We have already built and run it on Windows. Now, we are going to first deploy it to an Android device and then to iOS.

This is a one-time preparation for mobile development that you need to go through after Delphi is installed. We want to get to the point that you can see your devices as targets inside theProject Manager.

For Android, all steps to configure your system to detect your device are described athttp://docwiki.embarcadero.com/RADStudio/en/Configuring_Your_System_to_Detect_Your_Android_Device.

Deploying to Android

Deploying apps from Delphi to Android devices is simpler then deploying to iOS. You only need to have an Android device and a USB cable to connect your device to a Windows machine where you have Delphi installed.

Before deploying to an Android device, you need to find out if your device is supported by the version of Delphi you are using. For details, consulthttp://docwiki.embarcadero.com/RADStudio/en/Android_Devices_Supported_for_Application_Development for the list of currently supported Android versions.

The first step is to enable USB debugging on the device. This option can be set inDeveloper options on your device. This option is not easy to find. It is, in fact, hidden. On your Android device, go to theSettings |About menu. Tap theBuild number seven times to makeSettings |Developer options available. Then, check theUSB Debugging option. Connect your Android device with a USB cable to a computer where your PC is running. If you are using VMware make sure that your Android device is connected to the virtual machine where you have Delphi and not to your Mac. The first time you connect your Android device, you may see a message displayed on the device toAllow USB debugging from the computer, identified by a string of hexadecimal numbers that represents the computer's RSA key fingerprint. Check theAlways allow from this computer option and click onOK.

More info on enabling USB debugging on Android devices is available athttp://docwiki.embarcadero.com/RADStudio/en/Enabling_USB_Debugging_on_an_Android_Device.

The next step is to install the USB driver for your Android device on the machine where Delphi is installed. The test device that I'm using is Google Nexus 7.

Probably the easiest option to download all the necessary bits for Android development is to download and install Android Studio for free from Google. It will download all necessary Java SDKs and tools that are needed in order to build an Androidapk executable file. For reference, I'm using Android Studio version 2.2.2. On the splash, select theAndroid SDK option. In the dialog, select theSDK Tools tab and check theGoogle USB Driver option. ClickOK and the driver will be downloaded and installed, as shown in the following screenshot:

Android SDK Tools with the "Google USB Driver" option checked

In order to make sure that the device driver has been installed successfully, go to theDevice Manager window inControl Panel and you should find your device listed. If you right-click on the device, there is an option toUpdate Device Driver. I could find my Nexus 7 listed there and the device driver was up to date. Refer to the following screenshot:

Nexus 7 in Device Manager

Depending on your device, the steps may be different. You can find detailed information on how to install the USB driver for your Android device athttp://docwiki.embarcadero.com/RADStudio/en/Installing_the_USB_Driver_for_Your_Android_Device.

Now, back to Delphi IDE. Make sure that ourDelphiHelloWorld project is still open in the IDE. In theProject Manager, expandTarget Platforms and click onAndroid. The first time you click on theTarget node, you will see the messageAndroid SDK tools are required. Do you want to download and install Android SDK tools automatically?. Click onYes. The process to download and install SDK tools will start and you will see in the Command Prompt window the progress of the operation. After a moment, you should see your device listed underTools in theProject Manager.

Double-click on theAndroid node to select the Android target. It should display in bold font. Now this is the current target, so when you click on the Run green arrow, the IDE will build our Delphi Hello World app using the Delphi Android compiler and the executableapk Android file will be created, deployed to the device, and run in just one operation.

Click onRun. The project will be compiled, deployed to your Android device, and run:

Delphi "Hello World" app running on Android

You can find more information about preparing your IDE for running apps on Android devices on DocWiki athttp://docwiki.embarcadero.com/RADStudio/en/Android_Mobile_Application_Development.

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 specialPAServer Mac program on the machine where you have Xcode installed. ThePAServer19.0.pkg installable package is installed in thePAServer 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 thei 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 theProject 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 ourDelphiHelloWorld project is open in the IDE.

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

Then, selectAdd New from the connection profile combo. TheCreate a Connection Profile wizard will be displayed. I have enteredDelphiDev as the profile name. Click onNext. On the next tab of the wizard dialog, we need to enter the address and port of the remote machine. Keep the default port64211 and enter your Mac password in the last field. Now click on theTest 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 onFinish, as shown in the following screenshot:

"Create a Connection Profile" dialog

Now, back in theAdd a New SDK dialog, select the SDK version to add and click onOK:

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-bitTarget node and you should see your device listed there:

Project Manager with an iPhone device listed as a target

Now click on theRun button. This will locally build the iOSipa 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 athttp://docwiki.embarcadero.com/RADStudio/en/IOS_Mobile_Application_Development.

Download code iconDownload Code

Key benefits

  • A one-stop guide on Delphi to help you build cross-platform apps
  • This book covers important concepts such as the FireMonkey library, shows you how to interact with the Internet of Things, and enables you to integrate with Cloud services
  • The code is explained in detail with observations on how to create native apps for Ios and Android with a single code base

Description

Delphi is the most powerful Object Pascal IDE and component library for cross-platform native app development. It enables building natively compiled, blazingly fast apps for all major platforms including Android, iOS, Windows, Mac, and Linux.If you want to build server-side applications, create web services, and have clear GUIs for your project, then this book is for you. The book begins with a basic primer on Delphi helping you get accustomed to the IDE and the Object Pascal language and will then quickly move on to advanced-level concepts. Through this book, we’ll help you understand the architecture of applications and will teach you the important concepts of the FireMonkey library, show you how to build server-side services, and enable you to interact with the Internet of Things. Towards the end, you will learn to integrate your app with various web services and deploy them. By the end of the book, you will be able to build powerful, cross-platform, native apps for iOS and Android with a single code base.

Who is this book for?

If you want to create stunning applications for mobile, desktop, the cloud, and the Internet of Things, then this book is for you. This book is for developers who would like to build native cross-platform apps with a single codebase for iOS and Android. A basic knowledge of Delphi is assumed, although we do cover a primer on the language.

What you will learn

  • * Understand the basics of Delphi and the FireMonkey application platform as well as the specifics of Android and iOS platforms
  • * Complete complex apps quickly with access to platform features and APIs using a single, easy-to-maintain code base
  • * Work with local data sources, including embedded SQL databases, REST servers, and Backend-as-a-Service providers
  • * Take full advantage of mobile hardware capabilities by working with sensors and Internet of Things gadgets and devices
  • * Integrate with cloud services and data using REST APIs and scalable multi-tier frameworks for outstanding multi-user and social experience
  • * Architect and deploy powerful mobile back-end services and get super-productive by leveraging Delphi IDE agile functionality
  • * Get to know the best practices for writing a high-quality, reliable, and maintainable codebase in the Delphi Object Pascal language

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date :Jun 30, 2017
Length:506 pages
Edition :1st
Language :English
ISBN-13 :9781786465849
Vendor :
Embarcadero Technologies
Category :
Languages :

What do you get with eBook?

Product feature iconInstant access to your Digital eBook purchase
Product feature icon Download this book inEPUB andPDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature iconDRM FREE - Read whenever, wherever and however you want
OR

Contact Details

Modal Close icon
Payment Processing...
tickCompleted

Billing Address

Product Details

Publication date :Jun 30, 2017
Length:506 pages
Edition :1st
Language :English
ISBN-13 :9781786465849
Vendor :
Embarcadero Technologies
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99billed monthly
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconSimple pricing, no contract
$199.99billed annually
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick iconExclusive print discounts
$279.99billed in 18 months
Feature tick iconUnlimited access to Packt's library of 7,000+ practical books and videos
Feature tick iconConstantly refreshed with 50+ new titles a month
Feature tick iconExclusive Early access to books as they're written
Feature tick iconSolve problems while you work with advanced search and reference features
Feature tick iconOffline reading on the mobile app
Feature tick iconChoose a DRM-free eBook or Video every month to keep
Feature tick iconPLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick iconExclusive print discounts

Frequently bought together


Expert Delphi
Expert Delphi
Read more
Jun 2017506 pages
Full star icon4.6 (5)
eBook
eBook
S$53.98S$59.99
S$74.99
Delphi Cookbook
Delphi Cookbook
Read more
Jun 2016470 pages
Full star icon4.7 (10)
eBook
eBook
S$53.98S$59.99
S$74.99
Stars icon
TotalS$149.98
Expert Delphi
S$74.99
Delphi Cookbook
S$74.99
TotalS$149.98Stars icon

Table of Contents

13 Chapters
Fasten Your Seat BeltsChevron down iconChevron up icon
Fasten Your Seat Belts
Delphi installation
Delphi compilers and toolchains
Hello World app
Deploying to mobile devices
Summary
Mind Your LanguageChevron down iconChevron up icon
Mind Your Language
Do you speak Object Pascal?
Object Pascal Phrase Book
Summary
Packing Up Your ToolboxChevron down iconChevron up icon
Packing Up Your Toolbox
Parallel Programming Library
Working with files
JSON
XML
Summary
Playing with FireMonkeyChevron down iconChevron up icon
Playing with FireMonkey
Drawing in code
Get moving with timers
The power of parenting
Touch me
Game of Memory
Summary
FireMonkey in 3DChevron down iconChevron up icon
FireMonkey in 3D
Cross-platform 3D rendering
Using Context3D
Custom Wireframe component
Objects 3D
Moving Earth
Building an interactive 3D scene
Using 3D models
Starfield simulation
Mixing 3D and 2D
Summary
Building User Interfaces with StyleChevron down iconChevron up icon
Building User Interfaces with Style
Working with built-in styles
Using custom styles
Embedding styles as resources
Customizing styles
Using frames
Working with inherited views
Previewing forms on devices
Summary
Working with Mobile Operating SystemChevron down iconChevron up icon
Working with Mobile Operating System
James Bond's toy
What I'm running on?
The life of an app
Sensing the world
Taking photos
Using share sheets
Camera, light, action!
Working with address book
Notify me!
Navigating the web
Working with maps
Creating and consuming Android services
Delphi language bridges
Summary
Extending to the Internet of ThingsChevron down iconChevron up icon
Extending to the Internet of Things
Communication protocols
Understanding BLE
Connecting to things with ThingConnect
Getting close with beacons
Proximity solutions with BeaconFence
App tethering
Summary
Embedding DatabasesChevron down iconChevron up icon
Embedding Databases
Architecting data-driven apps
Modeling data
Choosing a database
Accessing databases with FireDAC
Building data-driven user interface
Using visual live bindings
Fast user interface prototyping
Summary
Integrating with Web ServicesChevron down iconChevron up icon
Integrating with Web Services
Understanding web services
Native HTTP client
Consuming XML SOAP web services
Integrating with REST services
Backend as a service client
Integrating with the cloud
Summary
Building Mobile BackendsChevron down iconChevron up icon
Building Mobile Backends
Delphi and multi-tier architectures
Getting low-level with WebBroker
Do it yourself with DataSnap
Easy REST API publishing with RAD Server
Summary
App DeploymentChevron down iconChevron up icon
App Deployment
Deploying to App Stores
Enhancing your apps
Summary
The Road AheadChevron down iconChevron up icon
The Road Ahead
What we have learned
Staying on top of everything
Your next Delphi mobile app
Summary

Recommendations for you

Left arrow icon
Debunking C++ Myths
Debunking C++ Myths
Read more
Dec 2024226 pages
Full star icon5 (1)
eBook
eBook
S$38.99S$43.99
S$53.99
Go Recipes for Developers
Go Recipes for Developers
Read more
Dec 2024350 pages
eBook
eBook
S$38.99S$43.99
S$53.99
50 Algorithms Every Programmer Should Know
50 Algorithms Every Programmer Should Know
Read more
Sep 2023538 pages
Full star icon4.5 (68)
eBook
eBook
S$47.99S$53.99
S$67.99
S$67.99
Asynchronous Programming with C++
Asynchronous Programming with C++
Read more
Nov 2024424 pages
Full star icon5 (1)
eBook
eBook
S$40.99S$45.99
S$56.99
Modern CMake for C++
Modern CMake for C++
Read more
May 2024504 pages
Full star icon4.7 (12)
eBook
eBook
S$47.99S$53.99
S$67.99
Learn Python Programming
Learn Python Programming
Read more
Nov 2024616 pages
Full star icon5 (1)
eBook
eBook
S$38.99S$43.99
S$53.99
Learn to Code with Rust
Learn to Code with Rust
Read more
Nov 202457hrs 40mins
Video
Video
S$101.99
Modern Python Cookbook
Modern Python Cookbook
Read more
Jul 2024818 pages
Full star icon4.9 (21)
eBook
eBook
S$53.98S$59.99
S$74.99
Right arrow icon

Customer reviews

Rating distribution
Full star iconFull star iconFull star iconFull star iconHalf star icon4.6
(5 Ratings)
5 star80%
4 star0%
3 star20%
2 star0%
1 star0%
GABRIEL OSWALDO DUQUE ZULUAGAApr 13, 2018
Full star iconFull star iconFull star iconFull star iconFull star icon5
Thanks!
Amazon Verified reviewAmazon
Israel PortilloDec 31, 2017
Full star iconFull star iconFull star iconFull star iconFull star icon5
Simply the best Delphi book in the market and the only one you need to master in the development of movil apps with a very understable English for a foreign language.Definitely Delphi continues to be one of the best programming language and books of this level will always be welcomed. As title say, this is not an introductory book in object pascal. If it is your case, look for Marco Cantu's book and then make expert yourself with this one.I know you are not in this world anymore Pawel, but I thank you for this book anyway.
Amazon Verified reviewAmazon
AnthonyMay 18, 2018
Full star iconFull star iconFull star iconFull star iconFull star icon5
well written gives you the information in a clear way without a lot of fluff.
Amazon Verified reviewAmazon
Pedro RiosAug 20, 2017
Full star iconFull star iconFull star iconFull star iconFull star icon5
Great book
Amazon Verified reviewAmazon
sbirnyMay 08, 2018
Full star iconFull star iconFull star iconEmpty star iconEmpty star icon3
Good book; already very useful. Well-organized and covers major topics in a way that is easy to understand. Website not so much. It is very difficult to navigate, find pertinent links (which don't point to the right stuff a lot of the time), and the worst part is they are trying to sell you something on every page instead of helping you with what you've bought. Least helpful website for any tech book I've bought recently.Will probably not buy from this publisher again. 5 stars for book, 2 stars for website.
Amazon Verified reviewAmazon

People who bought this also bought

Left arrow icon
50 Algorithms Every Programmer Should Know
50 Algorithms Every Programmer Should Know
Read more
Sep 2023538 pages
Full star icon4.5 (68)
eBook
eBook
S$47.99S$53.99
S$67.99
S$67.99
Event-Driven Architecture in Golang
Event-Driven Architecture in Golang
Read more
Nov 2022384 pages
Full star icon4.9 (11)
eBook
eBook
S$47.99S$53.99
S$67.99
The Python Workshop Second Edition
The Python Workshop Second Edition
Read more
Nov 2022600 pages
Full star icon4.6 (22)
eBook
eBook
S$50.99S$56.99
S$70.99
Template Metaprogramming with C++
Template Metaprogramming with C++
Read more
Aug 2022480 pages
Full star icon4.6 (14)
eBook
eBook
S$44.99S$50.99
S$63.99
Domain-Driven Design with Golang
Domain-Driven Design with Golang
Read more
Dec 2022204 pages
Full star icon4.4 (19)
eBook
eBook
S$43.99S$48.99
S$60.99
Right arrow icon

About the author

Profile icon Paweł Głowacki
Paweł Głowacki
Paweł Głowacki was Embarcadero's European Technical Lead for Developer Tools. Previously, Paweł spent over 7 years working as a senior consultant and trainer for Delphi within Borland Education Services and CodeGear. Apart from working with Embarcadero customers across the region, he represented Embarcadero internationally as a conference and seminar speaker. Paweł passed away in mid-December 2017, but he is alive in the hearts of the Delphi developers community, worldwide.
Read more
See other products by Paweł Głowacki
Getfree access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook?Chevron down iconChevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website?Chevron down iconChevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook?Chevron down iconChevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support?Chevron down iconChevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks?Chevron down iconChevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook?Chevron down iconChevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.


[8]ページ先頭

©2009-2025 Movatter.jp