« Real Studio Developer… | Home | MBS Real Studio Plugi… »

Reducing app size with #if

Sometimes people have applications made with Real Studio which are bigger than they need to be.
For example if you have an application which uses both NSStatusitem for Mac and SystemTrayItem for Windows. If you don't use #if and variant properties, your app probably has both plugin parts for Mac and Windows included in application.

Your dll folder for Windows may look like this:

Now if you put #if targetwin32 and #endif around them, the number of DLLs does not really go down. But now if you change the properties from "statusitem As NSStatusItemMBS" to "statusitem As Variant", you can get your app compiled without most DLLs. Of course if you want to use this property, you cast back to your normal class. For example you can have code like "dim s as NSStatusItemMBS = statusitem" and than use the local variable within the #if block.

Finally the DLL folder may look like this:

As you see there is no DLL here with Mac only classes.
Test project: appsizetest.zip
08 07 12 - 23:47