3

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?

Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
  • 1
    See [delphi-xe2-possible-to-instantiate-a-firemonkey-form-in-vcl-application](http://stackoverflow.com/questions/7315050/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 Dec 27 '11 at 10:32
  • 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 (http://www.midaconverter.com/) – philnext Dec 27 '11 at 11:27
  • 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 Dec 27 '11 at 13:19

3 Answers3

5

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.

Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
  • I accept your answer since it actually worked. I successfully managed to combine togather VCL and FMX forms in one since codebase and run them on Windows XP and Mac OSX. Details on how exactly I did it, sample screenshots and source code available at http://mtgs.blogspot.com/2011/12/how-to-create-and-application-which.html – Gad D Lord Dec 27 '11 at 22:58
  • Glad it helped. Thanks for the screenshots. Please also see my edit above: be careful with these IFDEFs. – Jeroen Wiert Pluimers Dec 28 '11 at 10:15
  • 1
    > The Delphi IDE owns DPR files, and will remove the IFDEFS, for when you add new forms or change some project properties. Just a little note. While earlier Delphi versions performed complete cleanup of IFDEFs in .dpr file's uses block on adding file, the Delphi XE5 version operates more gently, and does not touch IFDEFs for other units. – Aleksey Timohin Jan 01 '14 at 05:07
3

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...

Francesca
  • 21,452
  • 4
  • 49
  • 90
  • I already accepted Jeroen's answer since it led me to a working solution (http://mtgs.blogspot.com/2011/12/how-to-create-and-application-which.html). I voted your reply as well since studying the dproj may have been an easier approach to start with. – Gad D Lord Dec 27 '11 at 23:00
  • +1; I forgot about the name MonkeyMixer, thanks for bringing it up. And thanks for figuring out the .dproj setting. – Jeroen Wiert Pluimers Dec 28 '11 at 10:18
1

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.

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159
  • I know the pro/cons of having VCL+ FMX-based / conditioned application. FM is immature and buggy IMHO and lack great toolkits like TMS and DevExpress. I would like to keep my Windows users happy with cxGrid goodies and offer a completely new UI (based on 2D FM) for my new Mac users. The questions was not whether but how to force my IDE to display the "Add Mac OS" to my platforms menu. – Gad D Lord Dec 27 '11 at 13:16