A new build4D component has been available on GitHub for a few months. It empowers you to effortlessly create a compiled project or a component. Things are getting even better; this new component version will enable you to generate a single-user application, expanding the possibilities for your development workflow.
So with tool4D available since v20, integrating the application generation process into your CI (Continuous Integration) tools has become remarkably convenient.
Let’s delve into the details!
What does the component do?
Here is a non-exhaustive list of what the component allows you to do:
- compile the project,
- merge the 4D Volume Desktop with your project,
- add the information of the application like the Copyright, Company…,
- add the icon,
- choose the folders to add, like Documentation, WebFolder, Default Data…,
- select the folders to remove, like a Dev folder in the Resources,
- choose the modules to remove, like CEF, Mecab, php…,
- generate the deployment license,
- and sign the application.
What is the difference with the Build application command?
In both cases, you can generate a perfectly usable single-user application. The Build Application command is monolithic. If you want to customize a file or add or remove a folder, you must do it after building the application. And for a macOS application, you have to sign the application again.
The Build4D component is composed of several classes and functions coded in 4D. So if your application is very particular and different from others. You can easily add a new function or improve an existing one.
How to do it?
The code below is an example of generating a standalone application from an external project.
var $build : cs.Build4D.Standalone
var $settings : Object
var $success : Boolean
$settings:={}
// Define the external project file
$settings.projectFile:=Folder(fk documents folder).file("Contact/Project/Contact.4DProject")
// Configure the application
$settings.buildName:="myApp"
$settings.destinationFolder:="Test/"
$settings.obfuscated:=True
$settings.packedProject:=False
$settings.useSDI:=False
$settings.startElevated:=False
$settings.lastDataPathLookup:="ByAppPath"
// Define the 4D Volume Desktop path
$settings.sourceAppFolder:=Folder(fk documents folder).folder("4D v20.0/4D Volume Desktop.app")
// Specify the components required for compilation
$componentFolder:=Folder(fk documents folder).folder("4D v20.0/4D.app/Contents/Components")
$components:=[]
$components.push($componentFolder.file("4D WritePro Interface.4dbase/4D WritePro Interface.4DZ"))
$settings.compilerOptions:={components: $components}
// Delete the unnecessary module
$settings.excludeModules:=["CEF"; "MeCab"]
// Include the folders and files
$settings.includePaths:=[]
$settings.includePaths.push({source: $componentFolder.folder("4D WritePro Interface.4dbase").path; destination: "../Components/"})
$settings.includePaths.push({source: $componentFolder.folder("4D SVG.4dbase").path; destination: "../Components/"})
// Delete the folders and files
$settings.deletePaths:=[]
$settings.deletePaths.push("Resources/Dev/")
// Add the application icon
$settings.iconPath:="/RESOURCES/myIcon.icns"
// Add the application information
$settings.versioning:={}
$settings.versioning.version:="version"
$settings.versioning.copyright:="copyright"
$settings.versioning.companyName:="companyName"
$settings.versioning.fileDescription:="fileDescription"
$settings.versioning.internalName:="internalName"
// Create the deployment license file
$settings.license:=Folder(fk licenses folder).file("XXXXX.license4D")
// Sign the macOS appplication
$settings.signApplication:={}
$settings.signApplication.macSignature:=True
$settings.signApplication.macCertificate:="xxxxxx"
// Launch the build
$build:=cs.Build4D.Standalone.new($settings)
$success:=$build.build()
For more details on each attribute, read the documentation for each component class.
For macOS applications, you need to notarize them in order to distribute them. For more details, please refer to Apple’s documentation.
Next…
Go to GitHub to download the “Build4D” component. Moreover, to stay informed about all the new features of the component, click on the “Watch” button or put 4D Depot or Build 4D in your favorites. If you need help, you can read this blog post, which details all the 4D organizations and how to use all the Github features.