This week’s instalment of the UK-based Developer Direct webinar series is called iPhone/iPad Development with RAD Studio XE2. The following is a set of links and general information picked up during that broadcast and also during a US webinar by Anders Ohlsson (broadcast during the week and presumably to be available as an on-demand webinar after the fact) entitled Create Mobile iOS Apps using Delphi XE2 with FireMonkey.
Links:
- Get Started with Windows and Mac Development – intro to FireMonkey by DavidI
- 13 iOS Components and 8 Demos – FireMonkey components & demos for iOS by Anders Ohlsson
- Modifying FMX_Platform_iOS.pas to surface mainWindow and add device orientation support – blog post by Anders Ohlsson
- Anders Ohlsson’s iOS-related blog posts
- FMX_Dash iOS demo by Anders Ohlsson, showing GPS, compass, accelerometer & reverse geocoding
ReflectionReflector 2 – app to mirror your iPad or iPhone to your Mac desktop via AirPlay – you can find additional device mirroring techniques here.- TPlatform platform identification class documentation
- FireMonkey Development Setup for iOS – from documentation
- How to build a FireMonkey iOS application – article by Sarina duPont
- DataSnap connectivity for iOS using Delphi XE2 and FireMonkey –article by Anders Ohlsson showing how to use the Objective-C DataSnap Connector in FireMonkey iOS application. This is no longer required since the FreePascal DataSnap Connector was introduced in Update 4, but makes for good background reading.
- Develop Native FireMonkey iOS Apps with Delphi – video by Anders Ohlsson
- iOS development using FireMonkey: Working with the GPS and the Compass – video by Anders Ohlsson
- SQLite iOS Application Development with Delphi and FireMonkey - video by Anders Ohlsson from 31 Days of RAD Studio XE2 Video Tutorials – Day 9
- Developing an iOS Delphi and FireMonkey application with DataSnap and InterBase - video by Anders Ohlsson from 31 Days of RAD Studio XE2 Video Tutorials – Day 11
- Building and Using FireMonkey iOS Components - video by Anders Ohlsson from 31 Days of RAD Studio XE2 Video Tutorials – Day 18
Info:
- iPhone and iPad run an operating system called iOS, the current version of which (at the time of writing) is 5.1.1.
- RAD Studio runs on Windows. iOS development requires use of a Mac and also Apple’s Xcode development suite (this gives you the iPhone/iPad simulator and various tools to sign and package the app correctly).
- Additionally, the current toolset requires an intermediate step involving the FreePascal Compiler (FPC) inside Xcode to build (and debug) the iOS app. This is a temporary initial situation while waiting for Delphi to be able to target ARM processors.
- Caution: FPC is case-sensitive in terms of the uses clause!
- To target latest iOS and have all the bits you need, you need:
- a Mac with OS X 10.7.x (known as Lion) running.
- Xcode 4.2 (a slightly older version of Xcode that installs appropriate required command-line tools) installed on the Mac. You can get this from Apple’s Developer Downloads page (requires an Apple ID)
- Install on the Mac the packages from FireMonkey-iOS.dmg (installed by RAD Studio / Delphi on your Windows machine into a FireMonkey-iOS folder) to get:
- FreePascal Compiler (FPC), required to build your iOS app from within Xcode
- FireMonkey iOS Libraries – required files that FPC needs to build the iOS app on the Mac
- Xcode 4.3 – most recent update of Xcode, which supports the more recent iOS releases (5.x). Also worth noting that 4.3.x does not install some required command-line tools by default. One benefit of having installed 4.2 first is that you will have these tools installed. That said, you can download them in isolation from Apple’s Developer Downloads page (requires an Apple ID)
- Modify one of the iOS FMX support files, as per Anders’ post
- Install Anders’ iOS components into RAD Studio
- To get Xcode you need to join the Apple Developer Program (free). To deploy apps to a real device (iPad or iPhone) as opposed to the simulator, you need to join Apple’s iOS Developer Program ($99 per year to Apple) and create a Development Provisioning Profile. To deploy an app to the Apple App Store you need to create a Distribution Provisioning Profile. Plenty of information can be found in the RAD Studio documentation.
- When writing iOS code in Delphi XE2 these directives instruct the Free Pascal Compiler to support Delphi and Objective-C language features:
{$ifdef FPC}
{$mode delphi}
{$modeswitch objectivec1}
{$endif} - When Delphi targets ARM, the FreePascal dependency will be removed, as will the need to use the Xcode IDE. However some Xcode command-line tools will still be required on the Mac for signing, packaging etc. since Apple does not license these tools to third party tool vendors.
- iOS development from RAD Studio XE2 with FireMonkey is currently Delphi-only. C++ iOS support is pending, as per the recently published C++ roadmap. As soon as the C++ compiler targets ARM, then C++ will also directly generate iOS applications.
- When Delphi and C++ target ARM7, FireMonkey applications will support both iOS and Android directly from the IDE via new Target Platform options.
- Simplistic way of ensuring a screen full of controls laid out for an iPhone screen will fill up an iPad screen is to place all the controls on a TScaledLayout, perhaps with Align set to alFit as opposed to alClient.
- iOS apps should not proactively exit – they should only exit in response to the Home button. If you force an exit your app will likely not be approved by the Apple app review board.
- After creating an iOS app in Delphi XE2 you must also export it for Xcode consumption using dpr2xcode. This exported Xcode project needs to be available to Xcode on the Mac, so some shared drive is a sensible location to save the project to in the first place. A common way of working is to have Windows (and the RAD Studio/Delphi IDE) running as a guest OS in some VM software on the Mac (where OS X is the host OS), and storing the project in a directory that is shared between the host OS and guest OS. You could use commercial VM software such as VMWare Fusion or Parallels or even the Open Source VirtualBox.