How to Create Native Cocoa applications in Delphi XE2 (without FireMonkey)

While official Embarcadero materials emphasize only FireMonkey technology in light of creating MacOSX applications, it is yet very possible to create Cocoa applications w/ native MacOSX look and feel without using FireMonkey at all: Embarcadero have performed all the necessary job of translating Objective-C Cocoa headers to Delphi; compiler and debugger environment is working fine for non-FireMonkey applications.

So, in order to create 100% native Cocoa applications in Delphi XE2 you will have to master the following:

  1. Create simple OSX console application
    Learn how to create OSX console application in Delphi XE2 and debug it using PAServer (configure the environment, etc)
  2. Enhance OSX console Delphi application w/ simple NSApplication & NSApplicationDelegate code
    Learn the very basic of Cocoa: NSApplication & NSApplicationDelegate class/protocol — I recommend to study SampleNibblesApp source code thoroughtly
  3. Learn Cocoa, Xcode and how to design your interface in Xcode
    This is the most hard -- you must learn some Objective-C basics, Cocoa hierarchy, Xcode interface and how to create GUI in Xcode. I recommend to review AppleProgramming YouTube channel from the very beginning till very end.
  4. Enhance OSX Delphi application w/ loading of compiled NIBs
    You must be able to design Cocoa GUI in Xcode, compile XIB to NIB, write code in Delphi to load that NIB, implement IBOutlet and IBAction handlers in Delphi.

For example, I have taken CircleView sample application from MacOSX SDK and translated it one-to-one from Objective-C to Delphi — you can find compiled app and its Delphi source code attached below.

Ultimately it is quite possible to have Delphi XE2 cross platform app in form of native Windows GUI (VCL), native MacOSX GUI (Cocoa), shared business logic code, all implemented in Delphi.

AttachmentSize KB
CircleView.src.zip11.87 KB


Delphi tools?

Realy not better use FPC + XCODE? without Windows external installation.
P.S. I cannot use Windows, if i use it I lost my job.

Do you have any info on #4?

Interesting article! But I found it very short on details - it was an overview, I guess. I would be interested in a followup that examined each of these in more detail.

Specifically I'm interested in #4. What would be required to load a NIB in Delphi?

Post new comment

The content of this field is kept private and will not be shown publicly.