The MacView

Virtual Instrumentation from a Mac perspective

Wednesday, February 27, 2013

Build a Standalone Mac App in LabVIEW (no need to install the Runtime)

I just posted an example VI that Installs the LabVIEW Runtime Engine into your built apps. LabVIEW has added pre/post action VIs that you can add to your Build Application Specification. This can be very useful for automating prep-work or post-build tweaks.

One thing I have found that not many people are aware of is that you can embed the Runtime Engine in your LabVIEW built application. Since applications on the Mac are just folder (right click or control-click on an app and select Show package contents) you just need to create a folder inside your built app called "Support". Put the appropriate version of the LabVIEW Runtime Engine in that folder and now there is no need to include the LabVIEW Runtime Engine Installer.
Now the Runtime Engine is quite large (159MB for 2012), and some of that is due to items that you may not need. For some things it's obvious if you need it or not (if you're not using MathScript, you can delete the MathScript framework). Some things, if you delete them, can prevent the application from launching or working correctly. The VI I cooked up not only installs the correct version of the Runtime Engine (installed on your machine) but it also removes everything that is not needed to launch a simple VI.

Another reason the Runtime Engine is large is because there may be more than one architecture in the libraries. On the Mac, you can have what is called Universal Binaries, which includes native executable code for more than one processor in the same file. We have done this in the past to allow PowerPC and Intel code coexist in the same file. Some of our libraries may contain vestigial PowerPC code. If, in the future, LabVIEW were to support 64-bit Intel, it might have both 32-bit Intel and 64-bit Intel in the same binary. This VI also goes through every library in the Runtime Engine and strips out any code that is not 32-bit Intel.

We also ship a good amount of information in LabVIEW executable code to help us diagnose problems on users machines. You probably don't need all that diagnostic code, so in addition to installing the Runtime Engine, stripping out non-32-bit executable code, the VI also strips out any information that would help in diagnosing problems.

The Install Runtime also zips up your .app instal a zip file right next to the app (using the maximum zip compression). That way you have a standalone application in a zip file you can email or post to a web server, ftp site, or however you want to distribute your app.

Oh, and you know those annoying .aliases and Preferences files that are always dumped next to your app? Well, this post-build step VI will also remove those for you, leaving just the app and the zip file of the app.

Use this VI as a starting point. Modify it, hack it up, improve it. Please leave comments below of any recommended improvements or cool tricks you found for post-build steps.

Labels: , , , , , ,

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.