3
votes

I have a VCL application and pretty isolated VCL code. I would like to include Fire Monkey forms for Mac OSX support.

I plan using heavily IFDEF to determine should I build for Windows with VCL or for Mac OSX with FireMonkey.

Unfortunately there is no way to add MacOS platform from the Project Manager if the application is VCL one.

Is there a way to hack this somehow? Maybe manually tweak the .dpr and .dproj files?

3
See delphi-xe2-possible-to-instantiate-a-firemonkey-form-in-vcl-application. Not sure if making a windows and osx application from same code base is doable though.LU RD
If it is your own code (not 3d party one) you may consider to translate your project form VCL to FM with converter like MIDA (midaconverter.com)philnext
MIDA would fail on most of my GDI+ custom controls, DevExpress toolkit. I use just TActionList, TPanel and TForm from the standard VCL :) But thanks for the tip anyway.Gad D Lord

3 Answers

4
votes

What about doing it the other way around:

  • start with a FireMonkey application
  • add the OS X platform target
  • IFDEF it so that you can chooise between VCL or FireMonkey

It is not that hard to do this for a 1-form project, then add all the existing stuff from your current VCL dpr.

This might actually lead you to be able to figure out how the .dpr and .dproj of VCL and FireMonkey differ (I tried once, but it was too much to do in a short term way, so I shelved it for future research).

Note:

Be very careful when putting IFDEF in your DPR files. The Delphi IDE owns DPR files, and will remove the IFDEFS, for instance when you add new forms or change some project properties.

3
votes

Have you tried manually editing the dproj file to add OSX32 in the <Platforms> tag?

<Platforms>  
  <Platform value="Win64">True</Platform> 

  <Platform value="OSX32">True</Platform>  

  <Platform value="Win32">True</Platform>  
</Platforms>

You are probably aware of it, but in case you aren't, there is this MonkeyMixer plugin from Simon Stuart that can help adding the FMX forms to your project.

Note that I cannot really test any of that's for Mac, I'm still 100% Windows so far...

1
votes

It's a very good sign to have your VCL code isolated from the other code.

n-Tier architecture does make sense, and IMHO a full RAD approach is good for prototyping, but has some severe drawbacks for creating maintainable applications, with additional features.

The standard way of using Delphi XE2 is to use only FireMonkey forms and UI. Therefore, cross-compilation will be made easy. This does perfectly make sense, in term of maintability: once your FireMonkey code and forms are set, you can deploy them on several platforms, just by a recompilation. And do not forget that Linux will possibly be a target in the close future (DXScene was Linux and Android ready). Using a form converter may help you have the code using FireMonkey instead of the VCL.

If you only need some simple forms for Mac OS X, and expect a more complex application for Windows (which could be an idea, depending on marketing targets), you can create a pure FireMonkey "light" application. But I do not recommend using a lot of conditional define. Create a diverse project, with a proper FireMonkey platform. Then share all your non-VCL units among the VCL project and the FireMonkey project. You do not need conditional define for this pattern.