Allow selection of .app files using file browser in c#?

I'm working on a MacOS application built in Unity3D. I'm using a native file browser plugin to open native MacOS file dialogs for selecting files. In order to generate PDFs, my app relies on using Chromium's Headless/command line functionality.

On Windows, I can easily get the path to the included Microsoft Edge as that's standard, but on Mac, unless I guess and check (which I already do), there isn't a way to guarantee a Mac user has a Chromium-based browser installed.

So I intend on allowing the user to set the path manually by selecting the .app file with a file dialog. But even when I specify .app to be a valid extension, they still don't appear selectable.

I assume this is some sort of MacOS-specific limitation or default permissions, though I can't find much info on this online.

Using C#/DotNet s there any way of allowing this behavior as needed?

For some more info: I'm just running the application using System.Diagnostics.Process.Start() with command line arguments. Based on my experiments searching for Google Chrome (though Edge or Opera are just as usable), the path I'm looking for is: /Applications/ {{APP NAME}}.app/Contents/MacOS/{{APP NAME}} Because Contents isn't accessible by most users, I figured I would just automatically go in and grab the binary with the correct name once I have the path to the .app file.

I know I could include some lightweight version of ChromeDriver with my app, but I'd rather keep everything as self-contained as possible, especially as so many people already have Chrome (or Opera, Edge, etc) installed. The challenge is that not everyone has it installed in the same place, hence my need to make it customizable.

Any ideas or help would be appreciated! Thanks!

Replies

There’s a lot to unpack here. Let’s start with this:

In order to generate PDFs, my app relies on using Chromium's Headless/command line functionality.

macOS has a bunch of built-in APIs and tools that can generate PDFs. Whether they’re appropriate depends on your input data. What is that? That is, what are you trying to generate PDFs from?

Also, is your app sandboxed?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Please see my other post below for more details. Thanks!

Add a Comment

Hey, thanks for the reply!

To generate PDFs, I first create HTML documents using basic strings. Then I convert that HTML document to a PDF using Chromium's print to PDF feature.
I do this because 1) I also allow the user to export to just HTML if they want, skipping the PDF step, and 2) It's better for cross-platform development.

Interestingly, I only encountered this problem in the Unity Editor. Once I built the app into a standalone player, it did allow selection of .app files!

In terms of sandboxing: I'm not quite sure what you mean. Because I use my own authentication, licensing, and database implementation, I don't plan on publishing to the Mac App Store, and only distributing through my website. (Please no judgment there). I'm just building a standalone macOS application through Unity and distributing it from there (using a PKG)

I don't plan on publishing to the Mac App Store, and only distributing through my website. (Please no judgment there).

That’s fine. The reason I asked is that the Mac App Store requires that you enable the App Sandbox and the App Sandbox has a massive impact on your ability to find and run other code.

Interestingly, I only encountered this problem in the Unity Editor. Once I built the app into a standalone player, it did allow selection of .app files!

Weird. At this point I’m labelling this as a Unity-specific issue and I encourage you to escalate it via their support channel.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"