FireMonkey™ Development for iOS and OS X with ™ XE2

Graeme Chandler

From the WYN (What You Need) Series

2

Copyright © 2012 Graeme Chandler

All Rights Reserved

This material is protected by copyright. Some of this material is drawn from sources on the Internet, Embarcadero documentation and newsgroups. I will give credit where I am able to (or remember to). Please accept my apologies if I have omitted to give appropriate credit (and let me know).

The information is provided as-is and is, to the best of my knowledge and experience, correct at the time of writing.

This material should not be regarded as exhaustive or be relied upon to guarantee brilliant, bug free and dependable software. That is what your experience and testing are for. In other words, Coogara Consulting cannot be held responsible for your use of this material.

I welcome your comments and feedback to improve this material and my own knowledge of Delphi, FireMonkey, OS X, iOS, Apple and associated hardware software and technologies.

Delphi and FireMonkey are trademarks or registered trademarks of Embarcadero. Apple, OS X and iOS are trademarks or registered trademarks of Apple Inc. Windows is a trademark or registered trademark of Microsoft Corporation. Pentium is a registered trademark of Intel.

3

Table of Contents

About the Author ...... 12 Introduction...... 13 A note about spelling ...... 13 Who is this book for?...... 13 The structure of this book ...... 14 Abbreviations...... 15 Source code...... 15 Book format ...... 15 Training...... 15 Third Party Products ...... 15

Part 1. Overview and Setup ...... 16

1. About FireMonkey...... 16 What is FireMonkey ...... 16 FireMonkey Support in Delphi XE2 Editions ...... 16 Platform Requirements (according to Embarcadero) ...... 17 How does Delphi Support each Platform?...... 18 Delphi Libraries ...... 18 FireMonkey Libraries ...... 20 2. Preparing for Cross Platform Development...... 22 Connecting to a Mac ...... 22 3. Preparing for OS X Development ...... 25 Installing Support for OS X development ...... 25 The Platform Assistant...... 25 Delphi Remote Profile ...... 28 Writing a Test OS X Application...... 29 4. Preparing for iOS Development ...... 35 Installing Support for iOS Development ...... 35 Obtaining the Right Version of Xcode ...... 35 Installing Xcode...... 38 Xcode 4.2 Installation ...... 38 Installing Delphi XE2 FireMonkey Packages...... 40 Xcode 4.3 Installation ...... 42 Avoiding Moving to Lion (Staying on Snow Leopard)...... 45 Writing a Test Application...... 45 Simplifying Access to a Windows Share...... 52 Testing on an iOS Device ...... 54 Signing up for the iOS Developer Program...... 54 Provisioning...... 56 Using Xcode...... 65 The Organiser...... 65 Navigators...... 67 Project Summary...... 68 Project Info/Settings...... 69

4

Part 2. FireMonkey Nuts and Bolts...... 70

5. Inside FireMonkey...... 70 Global Variables ...... 70 Component Categories...... 71 Forms ...... 72 Placing Components ...... 73 Scaling...... 74 Frames...... 74 TControl...... 76 Parenting ...... 76 Align ...... 76 AutoTranslate...... 78 CanClip, ClipChildren, ClipParent ...... 78 DesignVisible...... 79 Margins ...... 79 Padding ...... 79 Position ...... 80 RotationAngle...... 80 RotationCenter ...... 80 Scale...... 81 6. Image Controls...... 82 TImage (Shapes Category) ...... 82 TImageControl (Standard Category) ...... 82 TImageViewer (Additional Category)...... 83 TPaintBox ...... 84 TImage3D (3D Layers Category) ...... 85 7. Button Controls...... 86 TButton (Standard Category)...... 86 TSpeedButton (Additional Category)...... 86 TBitBtn ...... 87 TCornerButton (Additional Category)...... 87 8. Styles...... 89 Changing Application Style at Runtime - External Style File...... 89 Changing Form Style at Run Time ...... 91 Changing Application Style at Runtime Using Resources ...... 93 Multiple TStyleBook Components ...... 94 Apply Styles to Individual Controls ...... 94 Inside a TButton Style ...... 96 Inside a TCheckBox Style ...... 98 Creating a Whole New Style...... 99 Creating a Gradient Style...... 100 Resolving Style Names...... 102 Pressed Button Style ...... 103 9. Effects...... 104 Effect Triggers ...... 104 Applying Effects in Code...... 105 Performance ...... 106 10. Animations...... 107 AnimationType and InterpolationType...... 108

5

Image Fade-In ...... 109 Pulse Animation...... 110 Path Animation ...... 113 Key Animations ...... 115 TColorKeyAnimation ...... 115 TFloatKeyAnimation ...... 116 TBitmapAnimation ...... 116 TBitmapListAnimation...... 117 Other Animation Types...... 117 11. Multilingual Support - TLang ...... 118 12. 3D Applications...... 121 3D Effects in a 2D Application...... 121 3D Objects ...... 125 Object Positioning...... 127 The Camera...... 129 Screen Projection ...... 134 Lighting...... 137 Materials ...... 139 Models...... 144 Further Reading ...... 149 13. Component Writing...... 151 Styles Review...... 151 Platform Targeted Styles...... 154 Component Styles ...... 155 Component Style Resources ...... 156 A More Functional Component ...... 162 Nitpicking ...... 167

Part 3. iOS Application Development ...... 169

14. Getting Started - Tips and Tricks...... 169 Code Editing and dpr2xcode...... 169 Creating Forms at Runtime...... 169 Scrollable iOS Applications...... 170 Form Size...... 170 Directives...... 171 Device Orientation...... 172 Determining Device Orientation...... 173 iOS Screen Size...... 173 Application Events...... 173 Keystroke Events ...... 174 TEdit ...... 174 Timers ...... 174 Dialog Appearance...... 175 Code Signature Error ...... 176 In-App Purchase...... 176 Change the iOS Home Screen Display Name...... 176 15. Inside Compiler for iOS...... 178 A simple example ...... 179 NSString and Other Objective-C Things ...... 180

6

String handling...... 181 16. iPhoneAll Examples and Classes...... 183 NSString...... 183 NSTimeZone...... 184 NSDate...... 185 NSPathUtilities ...... 186 Collection Classes...... 186 NSArray and NSMutableArray...... 186 NSDictionary and NSMutableDictionary...... 187 NSSet, NSMutableSet and NSCountedSet ...... 187 17. Opening URLs...... 189 Opening a URL in Safari ...... 189 Opening a Map to a Location...... 189 Dialling a phone number...... 190 Sending Mail...... 190 Other Protocols and Special Items...... 192 18. UIApplication ...... 193 Ignore Interaction Events...... 193 Set Status Bar Style...... 193 Showing and Hiding the Status Bar...... 194 Resizing the Form...... 195 A Programmatic Solution ...... 197 A Hack Solution...... 200 Application Badge Number ...... 201 Shake Edit ...... 202 19. The Virtual Keyboard ...... 203 Content Obscured by the Keyboard...... 205 20. Data Storage ...... 209 The iOS File System ...... 209 File I/O...... 213 Structured File I/O ...... 216 XML...... 221 Sharing Data Between Applications ...... 221 SQLite...... 221 Units...... 221 Data Types ...... 222 Omitted Features...... 223 Connecting to a Database using TSQLite (SQLite3db.pas) ...... 223 Connecting to a Database using TSQLite3Connection (sqlite3conn.pp) ...... 225 Deleting Records...... 228 SQLite Forums...... 229 DataSnap...... 229 The Server...... 229 The Client...... 234 Cloud Storage...... 238 A Third Party Option ...... 238 21. Storing Settings - NSUserDefaults...... 239 22. Application Resources ...... 241 Adding Resources to an Application Bundle...... 241 Accessing Files in the Bundle...... 244

7

23. Splash Screens and Icons ...... 246 Graphics Dimensions...... 247 Naming Conventions ...... 248 Automatic Icon Enhancements ...... 249 Adding Icons and Graphics to Your Project...... 251 24. Playing Audio ...... 253 AV Foundation Framework ...... 253 AV Foundation Framework Demo ...... 254 OpenAL Framework ...... 256 OpenAL Demo 1...... 257 OpenAL Demo 2...... 258 25. Background Tasks ...... 259 26. Using the Camera...... 262 Choosing an Existing Picture...... 265 Taking a Photo ...... 266 Saving a picture...... 266 27. Application Performance Monitoring...... 269 28. Portal Provisioning ...... 272 Adding a Device ID ...... 272 Adding an App ID...... 274 Development Provisioning Profile...... 275 Downloading a Provisioning Profile...... 276 Installing the Provisioning Profile ...... 277 29. App Store Submission...... 278 App Store Review Guidelines...... 278 iTunes Connect ...... 278 Contracts ...... 278 Distribution Provisioning...... 281 Preparing the Application ...... 282 Armv6 and Armv7 ...... 283 Building...... 285 Preparing for Application Submission...... 287 Company Name ...... 288 Application Information...... 288 Availability and Pricing Tier ...... 288 Product Version ...... 289 Product Rating ...... 289 Metadata...... 290 EULA...... 290 Uploads ...... 290 Large App Icon ...... 291 iPhone and iPhone Touch Screenshots ...... 291 iPad Screenshots ...... 291 Review Time...... 295 30. Additional Resources...... 296 FireMonkey Class Diagram ...... 296 Anders Ohlsson...... 296 TMS Software...... 296 MonkeyStyler.com...... 296

8

Part 4. OS X Application Development ...... 298

31. The OS X File System...... 298 Separation by Domain...... 298 Folders and Their Uses ...... 299 Special Folder Locations...... 300 OS Version Information...... 303 32. The Application...... 305 OS X Libraries ...... 305 Deployment Manager...... 305 Printing...... 308 Converting VCL Programs ...... 309 33. User Interface Design ...... 311 34. Cross-Platform Shared Libraries...... 313 Loading Libraries...... 313 Exporting Methods...... 313 Building with Run-time Packages ...... 314 LoadLibrary ...... 314 35. The Mac Developer Program...... 315 Membership Levels...... 315 App Store Review Guidelines...... 316

Appendix A - Components...... 317 Control position ...... 317 Rotation...... 317 Standard Category...... 317 TMainMenu - FMX only ...... 317 TPopupMenu - FMX only ...... 317 TStyleBook ...... 317 TCalloutPanel ...... 317 TImageControl...... 318 TPathLabel...... 318 TExpander...... 320 TSwitch...... 320 TToolBar...... 320 TListBox ...... 320 TComboBox...... 321 Additional Category...... 321 TCornerButton ...... 321 TArcDial ...... 321 TAniIndicator...... 321 TDropTarget ...... 321 TImageViewer ...... 322 TNumberBox ...... 322 TComboTrackBar ...... 323 TClearingEdit...... 323 TPlotGrid ...... 323 LiveBindings Category - FMX only...... 324 TBindingsList ...... 324 TBindScope...... 324

9

TBindScopeDB...... 324 TBindNavigator ...... 324 Cloud Category...... 324 TAzureConnectionInfo ...... 324 TAmazonConnectionInfo ...... 324 Grids Category...... 324 TGrid...... 324 TStringGrid...... 325 THeader...... 326 Common Controls Category ...... 326 TTabControl...... 326 Animations Category ...... 327 Colors Category ...... 327 THueTrackBar ...... 327 TAlphaTrackBar ...... 327 TBWTrackBar...... 328 TColorQuad, TColorPicker, TColorBox ...... 328 TGradientEdit ...... 329 TColorPanel ...... 329 TComboColorBox...... 330 TColorButton ...... 330 TColorComboBox...... 330 TColorListBox ...... 331 Effects Category...... 331 Viewports Category ...... 331 TViewport3D ...... 331 Shapes Category...... 331 TText...... 331 TPath...... 332 TImage ...... 332 TPaintBox ...... 332 TCalloutRectangle ...... 332 TSelection ...... 332 TSelectionPoint...... 332 3D Scene Category ...... 333 TCamera...... 333 TLight ...... 333 TDummy...... 333 TProxyObject...... 333 3D Shapes Category...... 333 3D Layers Category...... 334 TBufferLayer3D ...... 334 TLayer3D...... 334 TTextLayer3D...... 334 TImage3D ...... 335 Layouts Category...... 335 TLayout...... 335 TScaledLayout ...... 335 TGridLayout ...... 336 TScrollBox...... 336

10

TVertScrollBox...... 336 TFramedScrollBox...... 336 TFramedVertScrollBox...... 336

Index...... 337

11 About the Author

About the Author Graeme Chandler has been a software developer since 1980 with experience in over a dozen languages including Fortran, Assembler, Pick, C#, Java and Delphi.

As a trainer, he is respected for his technical knowledge and practical experience. From 2001 to 2003 he provided Delphi training for Borland Australia. In 2003 he began developing his own training material as Coogara Consulting, training in Delphi, C# and Delphi Prism. People have come from as far away as the Philippines to be trained.

When not working, he makes pens ( http://www.strikingwood.com.au ) and enjoys the country life in regional Victoria, Australia, with his wife and two cats.

You can contact Graeme via the Contact page at http://www.coogara.com.au

12 Introduction

Introduction Borland released Delphi 1 in 1995. It was a continuation of Borland's Pascal products that began, before Borland, with Anders Hejlsberg's Blue Label Pascal compiler in 1981. There was much discussion about how many newsgroups were required to support the early Delphi community. At the time it seemed that three would be sufficient.

Time has passed and how things have changed. Since Delphi 1 there have been 19 releases covering Delphi, Kylix, Delphi Prism and RAD Studio. There are now dozens of newsgroups, some of the more recent supporting the FireMonkey application platform. With FireMonkey, Delphi developers can now program for iOS devices and OS X as well as Windows.

In the first FireMonkey release we can't expect everything. We can't expect the perfect melding of Windows-based development and OS X or iOS deployment. But it is a firm foundation on which Embarcadero can be expected to build.

This book is about FireMonkey development. Much of the platform-specific material focuses on iOS. Being cross platform, much of what you learn can be applied equally to OS X and Windows.

A note about spelling I am Australian and prefer to spell in the British style. However, for consistency with the spelling of reserved words and property names in Delphi and other programming languages, "colour" will be spelled without a "u" and "centre" will be spelled "center". No doubt there are other examples of this.

Who is this book for? If you are new to FireMonkey then this book is for you. It will guide you from setup and installation on your Mac to deployment on iOS devices and submission to the App Store.

While a lot of the FireMonkey information in this book applies equally to iOS and OS X, this book is definitely more about iOS than OS X. If you are looking for significant content specifically aimed at OS X then this book may not be for you. However, it will introduce you to OS X, the file system and related information as well as a great many FireMonkey features you can use on OS X.

I have tried to provide reasonably detailed instructions for doing things on a Mac. If you are relatively new to OS X then the additional instructions and screen shots may be helpful. And if you know better than me, and I seem to be doing things on the Mac in a less than ideal manner, please let me know.

This book is not about the Delphi Pascal language. It is about capitalising on your existing Delphi skills to program for OS X and iOS. If you could benefit from Delphi training, please contact me about group or individual rates.

13 Introduction

The structure of this book This book is divided into four parts:

Part 1 provides an introduction to FireMonkey and describes what you need to get started. It introduces you to the resources required from Apple and shows you the steps to set up your Mac and Windows environments for both OS X and iOS development.

Part 2 looks inside FireMonkey at the nuts and bolts: the global Application, Screen and Platform objects, component categories and forms. Along the way we cover the differences in fundamental classes such as TControl and image and button controls. More than 25 pages are spent looking at styles, effects and animations before moving on to multilingual support. Another 25 pages is spent examining 3D applications and controls including cameras, lighting and materials and dealing with models. Finally we look at component writing, the impact that styles have on how we write components for FireMonkey and the considerations that need to be given to multi- platform components.

Part 3 looks at iOS application development and the parts that Delphi, the Free Pascal Compiler (FPC) and Xcode play. A lot of tips and tricks are provided as well as insight into some traps for the unwary. Some of the Objective-C classes are examined with guidance for obtaining more information about this vast API via the classes installed with FPC. Opening URLs of all sorts, collection classes, sending mail and UI elements such as the status bar are covered before we move on to data storage on iOS devices. Data Storage covers the file system and techniques for writing data locally using a variety of techniques, as well as the use of DataSnap. We look at how to include and access resources in the application bundle, play sound and perform background tasks and capture pictures with the camera. After seeing how to provision an iOS device in the online Provisioning Portal you are guided through the submission of an application to the App Store. Making money is then up to you!

Part 4 provides a broad overview of OS X development. With so many FireMonkey elements covered in earlier sections, and with so much in common with Windows desktop development, this section covers the essentials such as the file system, Delphi's OS X libraries and the project Deployment Manager.

Appendix A gives an overview of many of the FireMonkey components. Components that are basically a FireMonkey equivalent of existing Delphi components are not covered. It is expected that you are familiar with them.

14 Introduction

Abbreviations

API: Application Programming Interface FMX: FireMonkey for Windows and OS X FMI: FireMonkey for iOS FPC: Free Pascal Compiler GPU: Graphical processing unit SDK: Software Development Kit ADUG: Australian Delphi User Group APNs: Apple Push Notification service

Source code

The source code for examples in this book are available to purchasers of the book.

If you purchase this book directly from Coogara Consulting you will be provided with details about the source code download. If you purchased this book on the Amazon Kindle store, contact Coogara Consulting for information about obtaining the accompanying source.

Book format

The book may be purchased in either PDF or Mobi formats or in printed format directly from Coogara Consulting. Mobi is suitable for Kindle and other devices. The book may also become available from the Amazon Kindle store.

Training

Delphi and FireMonkey training are available in Australia. Contact the author for more information or visit http://www.coogara.com.au/Training.aspx .

Third Party Products

Some third-party products are mentioned. I have no personal affiliation with the companies producing them and, unless stated otherwise, have not undertaken an assessment of their usefulness. They are mentioned only as relevant products that may be useful to developers.

15 Part 1. Overview and Setup

Part 1. Overview and Setup

1. About FireMonkey

What is FireMonkey FireMonkey is a Delphi application platform released with Delphi XE2. It allows applications to be built targeting the MS Windows and Apple OS X or iOS platforms.

The distinguishing characteristics of FireMonkey applications include their presentation and cross platform capabilities. Leveraging the power of the GPU, FireMonkey applications are capable of performing, with ease, visual feats that would otherwise require considerable additional programming or special libraries, programming directly against the GPU via DirectX, OpenGL or similar libraries.

Consider the kinds of behaviour seen on iPhone and iPad devices: applications sliding in and out, display elements contracting, sliding and spinning, responsive gesture- based interaction including swiping, pinching, expanding, both single-finger and multiple-finger gestures.

The effectiveness of such features is driven by the GPU. One of the limitations imposed by this requirement is that the computer on which the application is deployed must have a qualified GPU - generally this is not an issue, even in virtual machines. See the next section for installation requirements.

FireMonkey Support in Delphi XE2 Editions According to the Embarcadero product feature matrix, the FireMonkey platform provides the following support in the various Delphi editions:

Feature Architect, Ultimate, Starter Enterprise, Professional Create 32-bit Windows applications for , X X Vista and XP; Server 2003 and 2008 Create 64-bit Windows applications for Windows 7, X Vista and XP; Server 2003 and 2008 Create OS X 10.6 and 10.7 applications X Create applications for iOS 4.2 and higher X

Note This material, including installation instructions, assumes that Delphi XE2 update pack 4 and the Update 4 hot fix are installed.

16 About FireMonkey

Platform Requirements (according to Embarcadero)

Microsoft Windows

• Delphi XE2, C++Builder XE2 or RAD Studio XE2 • Intel® x86-compatible, Pentium® 4 or later • Basic GPU – Any vendor DirectX 9.0 class or better (Pixel Shader Level 2) • 32-bit or 64-bit Windows: • Microsoft® Windows 7 • Microsoft® ™ SP2 • Microsoft® Windows XP Home or Professional, SP2 or SP3 • Microsoft® Windows Server® 2003 SP1, 2008, or 2008 R2

Apple OS X

• Mac OS X 10.6 Snow Leopard or OS X 10.7 Lion over a local area network using an SSH, VNC or Windows file sharing solution • 2 GB RAM or more • OpenGL. All Intel Macs have a qualified GPU

Apple iOS

• Delphi XE2 or RAD Studio XE2 on the PC • Free Pascal version 2.4.4 on the Mac (installed by Embarcadero or by user; will be built in the product as 2.5.x) • On a Mac running Snow Leopard OS: • iOS SDK version 4.2 or 4.3 • Xcode 3.2.5 (paired with 4.2), 3.2.6 (paired with 4.3), 4.0.2 (paired with 4.3) • On a Mac running Lion OS: • iOS SDK version 4.3 • Xcode 4.2 • All iOS devices have a qualified GPU

The Xcode download includes the corresponding version of the iOS SDK.

Virtualisation Products for running in a virtual machine (host requires GPU)

• VMware Fusion 3 • VMware Workstation 7 • VMware Player 3

I am using VMware Fusion 4 with Lion as host and guest - no issues.

There are some important installation considerations and we will look at installation in a moment.

17 About FireMonkey

How does Delphi Support each Platform? To produce the kinds of visual transitions and transformations seen in iOS, and to run on different platforms, Delphi uses a few obvious and some less obvious techniques.

To begin with, different libraries are used for different OS targets. This may seem an obvious requirement, but along with the different operating systems, it has some interesting effects and imposes some important restrictions:

• Windows can target 32-bit and 64-bit. OS X is 64-bit and iOS is 32-bit (FireMonkey for OS X applications are 32-bit) • Many of the techniques learned in Windows will not be applicable to OS X and iOS and won't generally be available • If those techniques are available (i.e. the calls are available in code), they probably won't work on other platforms - forget your clever Windows API calls • You may need to learn additional techniques for different platforms • You may want to learn some Objective-C to help decipher the many on-line Xcode examples • You may find that your use of IFDEFs increases to accommodate differences in features available on each platform • You will need to use the Platform Assistant to debug OS X applications remotely from Delphi • Because iOS applications are compiled using the Free Pascal Compiler (FPC) under Xcode on OS X, the development/debugging cycle for iOS applications is made somewhat more difficult • Database storage and data access strategies need to be reconsidered

We will look at these issues and more as we progress.

Delphi Libraries It may be useful to know up front what libraries are used and what some of the obvious differences are. Details of the libraries are easily found in Delphi under Tools | Options.

18 About FireMonkey

Then select Environment Options | Delphi Options | Library

At the top of the dialog is a drop down. By default it shows 32-bit Windows and the collections of Library, Browsing and DCU paths (among others) that relate to the selected compiler target.

From the combo box can be selected 32- and 64-bit Windows and OS X. Notice that there is no mention of iOS. Whether or not you start a Win32 application or a FireMonkey iOS HD or 3D application these are the only options available. Before we discuss iOS let's look at the libraries that are involved in each of these targets:

32-Bit Windows - Library path:

64-bit Windows - Library path:

19 About FireMonkey

OS X - Library path:

A common feature of the non-32-bit targets is the use of the $(Platform) placeholder or simply a different path so that different libraries are referenced.

This is also true of the Debug DCU path:

32-bit Windows $(BDSLIB)\$(Platform)\debug $(BDS)\RaveReports\Lib 64-bit Windows $(BDSLIB)\$(Platform)\debug $(BDS)\RaveReports\Lib64 OS X $(BDSLIB)\$(Platform)\debug

We need to consider the FireMonkey library references (units) that are added to a project of type FireMonkey or FireMonkey for iOS (whether HD or 3D is not important at this stage).

FireMonkey Libraries A FireMonkey HD/3D application can run on Windows or OS X, while a FireMonkey HD/3D iOS application is targeted at portable Apple devices (the latter can be compiled and run on Windows, but the form is sized to simulate an iPhone). Recall, too, that iOS devices are 32-bit.

Therefore, there are going to be some differences in the library requirements for each scenario. These will relate to possible naming conventions and data types. For this reason there are two separate sets of libraries used to support FireMonkey.

If we start a FireMonkey HD application, the default Interface section uses clause in the main form will look something like this:

A FireMonkey HD iOS application Interface section uses clause in the main form will look something like this:

20 About FireMonkey

The obvious difference is the lack of the dotted naming convention. It looks like there are fewer units but they are the same.

So iOS does not permit multiple name parts - just the standard . format. To support this difference there are two folders of FireMonkey source code: one to support FireMonkey and one to support FireMonkey for iOS:

• C:\Program Files\Embarcadero\RAD Studio\9.0\source\fmx • C:\Program Files\Embarcadero\RAD Studio\9.0\source\fmi

Note The paths to both C:\..\fmx and c:\..\fmi are included in the Browsing path simultaneously. While, therefore, units from either folder can be added to the uses clause of a project, you must ensure that the correctly named unit is added according to your project target.

Digging a little further we can discover some of the other differences within individual units in the FMX and FMI libraries.

Conditional defines feature in the code, with $IFDEF references to FPC, IOS, MACOS and MSWINDOWS. FPC refers to the Free Pascal Compiler. There are a lot of $DEFINE statements in FMX_Defines.inc but it is not important to be familiar with them.

String references in iOS (FMI) are WideString whereas in non-iOS (FMX) they are Delphi's Unicode strings. Logically following on from this, the use of functions such as PWideChar appear in FMI and PAnsiChar in FMX code, TWideStringList in FMI and TStringList in FMX and so on. This difference does not mean that iOS cannot show multi-byte character sets. It does so without a problem. It is just a difference in the available data types.

In FMI, enumerations must be prefixed by the enumeration type (not allowed in Delphi Win32 applications). Using the MessageDlg function in FireMonkey will require a reference to TMsgDlgType.mtInformation, not just mtInformation (note also the difference regarding mbOK):

There are other differences as well, but generally they are issues concerning string types or minor differences in syntax.

Note For iOS compilation on the Mac the Xcode IDE is used. To enable compilation of Pascal code it uses the Free Pascal Compiler. There is a library of code on the Mac side that parallels the FMI libraries on the Windows side. We will look at this in the next section.

21