Best way to launch another Xojo App

Is there a better way than using Shell to launch another Xojo app from my Xojo app? I have tried both of the below methods and I am told that the path does not exist, yet it 100% does if I run the same exact commands from the console.

Dim appFI As FolderItem = New FolderItem(App.ExecutableFile.Parent.NativePath + "MyApp")
appFI.Launch
Dim sh As New Shell
Dim runPath As String = App.ExecutableFile.Parent.NativePath + "MyApp"
sh.Mode = 1 ' Asynchronous mode
sh.Execute(runPath)

Running on Linux so I assume I need to “chmod +x” the app first as well?

I can confirm that the paths that are generated are correct and point to the executable to launch.

I would instead try:

Dim appFI As FolderItem = App.ExecutableFile.Parent.Child("MyApp")
If appFI <> Nil and appFI.Exists Then
appFI.Launch
Else
MessageBox "appFI is missing"
End If

In addition to using child instead of + “myApp” a helper app should be in library/loginitems or library/helpers instead of contents/macOS. Or notarisation will complain.

thanks, it was a silly typo of mine and this helped.

If you’re going to use a shell, you’ll need to add a & to the end or use nohup. Otherwise the new app becomes linked to the shell object and to your app and will be quit when they are quit or destroyed.

1 Like