I’m building an installer for OSX. I have a XOJO desktop app that asks the user for his name, email address, and a registration code he was provided via email/browser. The project is an addon to MS Word 2011. At the end of the XOJO app, if the user has been validated by our server as having valid purchase and not exceeded the number of install allocations, I wish the necessary files to be installed. BTW, I use http.socket to send hardware serial numbers to the server and process the response to proceed.
I’ve used Iceberg to create a .pkg that will install all the necessary files; however, I need to launch this from my XOJO app. I’ve tried folderitem.launch, a shell script, and go nowhere. BTW the XOJO desktop app in launched as a Post-install script from a separate Iceberg .pkg
How do a launch/open a .pkg file and have it do it’s thing from XOJO (osx only)?
Hi Paul, you should be able to run the entire installer from within your Xojo app using the ‘installer’ command line tool. In fact (if I recall correctly) you can even get a progress % back so you can display a progress bar.
While I am here - you can move the prompt for the name, email address and registration code right into the original installer by building a “Installer Plugin”. It does require some Xcode work but would mean you wouldn’t need your separate app to request the info and validate the data before installing the final component/s.
Can I mention also that adding a user process like asking for registration etc during an install makes it very difficult for Mac admin’s to automate the deployment of your app. There are ways around that of course and it might not be a problem for you unless you envisage selling multiple copies to a single organisation who will want to deploy using an automated management tool.
Just something to consider.
I haven’t a clue about 'using the installer command line tool. Note I’m running an OSX Desktop version of XOJO. No console apps
What I’m selling is for a single user to use on up to two computers, typically a wannabe author or a college student writing an academic paper. Not for Mac admins. Not for corporate deployment.
Did a search for XOJO installer command line tool. Found nothing useful. I’m new to Mac and XOJO. Lines of XOJO code would be helpful
Right - so you’ll need to use the Shell class and execute the Mac OS X ‘installer’ command. It’ll look something like this (long hand version here);
Dim oShell As Shell
Dim shellCommand As String
Dim pathToPackage As String
Dim target As String
Dim error As Integer
oShell = New Shell
If oShell <> Nil Then
pathToPackage = “/tmp/yourInstaller.pkg” ’ pass the POSIX path to your pkg file.
target = “/” ’ boot drive
shellCommand = "installer -verbose -package " + pathToPackage + " -target " + targetDevice
result = oShell.ReadAll
’ You can check the error code here too…
error = oShell.ErrorCode
If error <> 0 Then
oShell = Nil
This code will execute the installer command for you… (well it should do) However because the default shell mode is Synchronous it will cause you app to pause while it completes. That could be a problem for you as well as meaning that you can’t show and update a progress bar. If that is a problem for you the change the mode to Asynchronous and capture the output in the DataAvailable event… I’ve done that many times for shell processes that can take a while and it works very well.
You should read the man page for installer also - loads of great info there.
In Terminal - type;
Hope that helps
Thanks David. I tried your shell approach myself earlier. Didn’t work…just ignored the command. (BTW, I think you may have meant the Shellcommand line to end with + target. not + targetDevice.) When running an 'installer…" from terminal, it doesn’t like it as it needs root authorization. I can prefix sudo and it asks for password. This will not work as it’s too confusing for my typical user.
I spent a lot of time in the weeds creating a script file (.sh). When I ran it, it started Microsoft Messenger. I turned to drink and opened a bottle of Merlot. Once I figured out the association for *.sh was set to Microsoft Messenger, I reset it to terminal. Is that the correct association? I don’t know how the association was set to Messenger. It’s a bit worrisome. I hope my users don’t have this disease. Anyway, I got it to work by creating a script file with “Bash Open MyInstallPackage.pkg” It opens the GUI of Iceberg/Installer and proceeds. It appears to be doing it correctly. I had to do the script solution to convince Iceberg to install in the User Home folder subfolders where Word stores user templates, but it appears to work.
Now, I’d like to ask a further question. I need to delete the .pkg file if the user cancels, doesn’t have the right credentials, has exceeded his allocated install, and at the end of the install. I tried to the following code.
dim f as FolderItem
MsgBox "User Cancelled. Installation Aborted"
f = SpecialFolder.SharedApplicationData.child("r4w").child("UserFilesinstallDlx.pkg")
If f <> Nil Then
if f.exists then
It just ignored the delete. The .pkg remained. Could be it thinks it’s a folder that isn’t empty. Suggestions?
Thanks again for your guidance.
The easy way is simply to use the .launch function.
Dim f as folderitem = <howeverYouGetYourInstaller>
If you want to suppress the installer GUI, it requires using the terminal and preferably SU access.
You should also codesign your packages and verify the code signature before you run the installer, this will prevent your application from installing files that didn’t come from you! i.e. If your server gets compromised, and your installers are replaced with something malicious.