Including a 2nd App within my App

I have a program that I would like to have call another program. I know that it’s easy enough to use FolderItem.Launch, but when packaging my program with the additional program, where should that program live? In the Resource Folder? I tried dragging the program into the IDE, but it kind made a mess of things.
What about when packaging it up as a dmg? Can an .app within an .app be packaged that way? I don’t know much about MacOS stuff, still learning!

The main program will be cross-platform Windows/MacOS and I would want a copy of the external app to go with the main app.

App in an App “might” be possible if the app is in and of it self a single EXE file
but most are not, especially if written with Xojo (and perhaps even most any more complex language).
They usually consist of a “bundle” with resources, plists and other required ancillary files inside a folder or other “application” container.

If you are looking for a deployment method… one suggestion (off the top of my head). is to ZIP the 2nd app, and include that in the resources of the 1st app (it would of course increase the “footprint” quite a bit). and then copy and unzip it when desired.

But you can’t “execute” the 2nd app while it is still “inside” the first one.

Having helper apps is quite common on macOS. Those either go into Library/Helpers or Library/Loginitems. It’s quite simple to make an IDE script to build multiple apps and copy the helper app into the main app when building. You also need to make sure that both apps are codesigned.

I do this routinely (helper app as Beatrix mentions) and copy to myApp.app/Contents/Resources/myHelperAppFolder/, whcih contains the built helper app and its Libs folder with all required dylibs. This way everything is self contained in a single app bundle without messing with your Library folders outside your app’s bundle. And you always have the path to your helper-app to launch it.
I use an Applescript to assemble everything before building an installer with Packages.

Thanks! I expect the signing and packaging into a DMG might be tricky?

Any examples of an IDE script that would copy the app into the correct folder?

And on Windows I would just copy the helper app into a similar folder as with MacOS - Resources\myHelperAppFolder\?

Some time ago I believe Sam discovered that helper apps can’t go in Resources and successfully be code signed. I don’t know for sure about a complete app bundle, but command line helpers go in .app/Contents/MacOS and login items go in .app/Contents/Library/LoginItems.

Edit: Using Postgres.app as an example, it looks like bundles go in MacOS as well.

It’s a CopyFiles step you want.
http://documentation.xojo.com/topics/build_automation/introduction.html#Copy_Files

With CopyFiles steps you can have this done automatically when you build. Select the correct destination in the Inspector panel.

From Apple’s (outdated) official code signing rules.

Contents/MacOS // - Helper apps and tools Contents/Frameworks // - Frameworks, dylibs Contents/PlugIns // - Plug-ins, both loadable and extensions Contents/XPCServices // - XPC services Contents/Helpers // - Helper apps and tools Contents/Library/Automator // - Automator actions Contents/Library/Spotlight // - Spotlight importers Contents/Library/LoginItems // - Installable login items Contents/Library/LaunchServices // - Privileged helper tools installed by the ServiceManagement framework

Thanks!
What’s the consensus? Contents/MacOS or Contents/Helpers?

Will one have a better chance than the other when trying to sign and notarize the whole kit and caboodle?

I assume there’s nothing “standard” for Windows?

I should’ve specified that i don’t do the App Store so never had to deal with signing etc. I suppose I should move my helper into Contents/Helpers/.

Now I’m a bit more awake. There are 2 parts for building:

  1. An IDE communicator script to build the apps:

dim basePath as string = userHome + “/Documents/Development/Mail\ Archiver/”

[code]'do scheduler
openfile(basePath + “code\ current/max\ scheduler.xojo_xml_project”)
if BuildApp(16) = “” then
return
else
DoCommand “SaveFile”
DoCommand(“CloseWindow”)
end if

'main app
openfile(basePath + “code\ current/max.xojo_xml_project”)
if BuildApp(16) = “” then
return
else
DoCommand “SaveFile”
DoCommand(“CloseWindow”)
end if[/code]

And so on.

  1. The apps have IDE scripts to copy the helpers into the correct place:

[code]'copy the scheduler to app/library/loginitems

'no scheduler for lite
if ConstantValue(“App.kMaxVersion”) = “2” then Return

dim appPath as string = currentBuildLocation + “/” + shellEncode(currentBuildAppName)
if right(AppPath, 4) <> “.app” then appPath = appPath + “.app”

'do directory for loginitems
dim cmd as String = "/bin/mkdir -p " + appPath + “/Contents/Library/LoginItems”
dim theOutput as string = doShellCommand(cmd)
if theOutput <> “” then print theOutput

'get path to scheduler
dim CountSlashes as integer = CountFields(ProjectShellPath, “/”)
dim ProjectName as string = NthField(ProjectShellPath, “/”, CountSlashes)
dim ProjectPath as String = Left(ProjectShellPath, Len(ProjectShellPath) - Len(ProjectName))
dim PathToScheduler64 as String = ProjectPath + shellEncode(“Builds - max scheduler/OS X 64 bit”)

'copy scheduler to app
cmd = "usr/bin/ditto " + PathToScheduler64 + " " + appPath + “/Contents/Library/LoginItems”
'print "cmd " + cmd
theOutput = doShellCommand(cmd)
if theOutput <> “” and instr(theOutput, “can’t get real path”) = 0 then print theOutput

// Helper functions for this script
Function shellEncode(inValue as string) as string
Dim rvalue as string = replaceAll(inValue, " ", "\ ")
rvalue = replaceAll(rvalue, “&”, “\&”)
rvalue = replaceAll(rvalue, “-”, “\-”)
rvalue = replaceAll(rvalue, “(”, “\(”)
rvalue = replaceAll(rvalue, “)”, “\)”)
return rvalue
End Function[/code]

The code isn’t especially robust because I have to set the paths manually. But the code doesn’t change too often so it’s not much of a problem.

My personal feeling is /Contents/MacOS/ as I’ve not seen a /Contents/Helpers/ in the wild. I don’t have any documentation or sources to back that up.

If one fails try the other and let us know the results!

(plug) I’ve spent a little bit of time researching code signing on Windows (/plug) and I can tell you that the location of a helper app wouldn’t break a signature on Windows. Each file is signed individually and there isn’t a “package seal” on it unless you implement your own. What’s stuck on my mind though is anti-malware software could make up some reason to complain.

Great stuff!

The helper app is complete and doesn’t need compiling, so that should simplify things I expect.

Peter, I’m not going to be using the App Store either, but it seems like signing and notarizing are needed for Catalina if you don’t want warnings and requiring users to do extra work. If there’s a way to get around that, I’d love to know, because these extra hoops are a PITA.

I’m still (happily) running High Sierra so never encountered the Catalina issues you mention. Yet another reason to stick with an OS release that works and doesn’t get in the way. Sorry, no idea how to work around the headaches you mention. But would be interested.
After Sam’s post, moved my helper and its dylibs into Contents/Helpers/. Works the same of course, but cannot say if it would muzzle Catalina’s complaints.

It won’t stop the insanity of Catalina, but making this change now will alleviate one code signing headache for the future, but don’t worry, I’m sure that there’ll be more to make up for it.

Under Windows, using a second app is quite simple, really.

Just make sure to sign the helper, and put it into the Resources folder with a copyfile step.

Then from within the app, use TPSF to point to the helper, and launch it.

It works perfectly in Desktop apps that have been placed in Program Files or Program Files (x86) by an installer.

In New API appx packed by Desktop App Converter (DAC) for the Windows Store, however, the helper simply don’t run. No crash, no error. Probably a security issue.

[quote=469949:@Andy Broughton]Great stuff!

The helper app is complete and doesn’t need compiling, so that should simplify things I expect.

Peter, I’m not going to be using the App Store either, but it seems like signing and notarizing are needed for Catalina if you don’t want warnings and requiring users to do extra work. If there’s a way to get around that, I’d love to know, because these extra hoops are a PITA.[/quote]
FWIW, our helper apps are stored in the Resources directory, are signed individually and are then notarized all together as one package when we notarize our distribution DMG. When we were first experimenting with notarization, just doing the .app bundle worked just fine too.