Lazarus Cross-Platform Project
Contents
Introduction
What's Included
How It Works
Acknowledgements
Introduction
The Lazarus Cross-Platform Project (LazXProj) adds
to Lazarus the ability to create cross-platform projects
with support for the following on Windows, Mac and Linux:
- App version information
- App preferences and settings
- App icons (.ico, .icns, .png)
- On Mac, proper menus and app bundle
- Install scripts for app (optional)
- When version info is edited in IDE, the Info.plist file, install scripts, etc.
will be updated automatically after next compile.
What's Included
A zip file with the source is available here.
AppXProj package
Cross-platform projects use the AppXProj package's
units, so make sure it's been compiled. You don't install the AppXProj package
in Lazarus, just compile it.
Note that you can use the AppXProj package or its units in any app, even non-LCL
apps. The AppXProj units have no dependence on any Lazarus package or unit.
fix_xproj console app
Open fix_xproj.lpi in Lazarus and compile it. This app is run after
each compile of a cross-platform project to check if any version info needs
to be updated.
You can also run this app yourself from the command line.
LazXProj package
Once the LazXProj package has been compiled and installed in Lazarus,
you can choose File | New and create a cross-platform project.
Note that cross-platform projects don't have a dependency on the LazXProj
package. This makes it easy to move the project to another computer where
LazXProj has not been installed in Lazarus. Just compile AppXProj and fix_xproj
and your cross-platform project is ready to compile.
How It Works
When you create a cross-platform project with File | New, LazXProj creates
your new project's folder and copies files from its templates,
icons and scripts subfolders into your project's folder.
These "boilerplate" files automatically add cross-platform support
to your app.
Once copied to your project folder, you can make any changes you want to
your project's files. For example, you'll probably want to replace the
project's icons with your own. To do that, just replace the project's default
.ico, .icns and .png files.
LazXProj adds a call to fix_xproj on the Compiler Commands tab of your
project's Project Options. After each compile, Lazarus will run this small
console app, which checks to see if any of the version info files need to
be updated. If you've edited the project's version info on the Version Info
tab, fix_xproj will update the project's version info files and install scripts.
On a Mac, fix_xproj makes sure the project's app bundle is properly updated
and named correctly. Since the app name may not be the same
as the target executable, it uses the target name to create a symlink to the
actual app bundle if they differ. This is required so Lazarus can debug the app.
If you let LazXProj create the optional installer scripts for your project,
fix_xproj also updates these if needed:
- projectname.iss - on Windows, compile this script with
Inno Setup
to create an .exe installer for the app.
- makedmg.sh - on Mac, run this script to create a .dmg installer for
the app.
- makedeb.sh - on Ubuntu, run this script to create a .deb installer
for the app.
Note: In Lazarus, a project's Version Info tab is a place to enter
Windows version information that will be included in a resource embedded in the
compiled Windows .exe. However, a number of the items entered there can also be
used with Mac and Linux apps. For more information, see these links:
Windows: VERSIONINFO resource
Mac: About Info.plist Keys and Values
Acknowledgements
LazXProj automates the addition of many of the tips described in this
ancient article:
Making Your Lazarus App Mac-Friendly.
LazXProj's default icons are based on a detail from the
Green chameleon
clip art. Although at first glance it may look like a chameleon riding a bicycle,
it's actually a branch.
Copyright 2016 by Phil Hess.
macpgmr (at) icloud (dot) com
First revision July 31, 2016; last edited Aug. 12, 2016.