« New MBS Plugin improv… | Home | MBS Filemaker Plugin,… »

Using dash if to reduce app size by referencing less plugins


if you build an app using some plugins on the Mac side for accessing Mac only frameworks, you may want to avoid those plugins being used on Windows. So for example if you build the "Show my entry" project, you get this list of DLLs in Libs folder for Windows:

MBS_ABAddressbook_Plugin_18034.dll
MBS_NSAttributedString_Plugin_18034.dll
MBS_NSBase_Plugin_18034.dll
MBS_NSColor_Plugin_18034.dll
MBS_NSImage_Plugin_18034.dll
MBS_QTImporter_Plugin_18034.dll
msvcp100.dll
msvcr100.dll
RBGUIFramework.dll

Okay, that may be too much for this as all MBS plugins are used only for Mac here. Now we can put "#if TargetMacOS" around all method's code and the open event. But this has first only the effect that we save MBS_QTImporter_Plugin_18034.dll file. But to really save the DLLs, we also need to make sure there is no method left using the plugins.

One way to do this, is to put things in a module. Methods and properties in the module are removed before linking if they are not called. So if you have trydate/trylabel/trystring methods in a module and also the "a as ABAddressBookMBS" property, than the linker can remove those for Windows and you have no MBS DLL on Windows for this sample.

Second possible way is to use variant data type. If methods declare parameter as variant instead of ABPersonMBS or ABMultiValueMBS, than the linker doesn't see the reference there. Of course you may want to have your parameter declared in the #if now. So parameter is "vperson as variant" and after "#if TargetMacOS" you write "dim person as ABPersonMBS = vperson". This was the compiler on Linux or Windows only sees variants and not all those plugin class names.

Project files: showmyentry.zip
see also Reducing app size with #if
21 10 13 - 19:12
No comments

  
Remember personal info?

Emoticons / Textile


Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.