Pages

Friday, 8 June 2012

FireMonkey iPhone/iPad links and info

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:

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.

1 comment:

  1. Great! I'm a newbie to the iOS development so such articles where everything is cleared out completely are of highest value for me.

    ReplyDelete