Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are we meant to use TophatKit externally? #65

Closed
luispadron opened this issue Jan 21, 2025 · 7 comments
Closed

How are we meant to use TophatKit externally? #65

luispadron opened this issue Jan 21, 2025 · 7 comments

Comments

@luispadron
Copy link

I'm trying to build an external extension (for 2.0) that reaches our private build network, I'm able to produce a .appex using TophatKit but not sure what to do with that. Is this supposed to be installed somewhere?

@luispadron luispadron changed the title How are we meant to external use TophatKit? How are we meant to use TophatKit externally? Jan 21, 2025
@lfroms
Copy link
Member

lfroms commented Jan 21, 2025

Hi @luispadron, extensions in macOS are supposed to be hosted within standalone macOS apps. The host macOS app need not necessarily be running, but its presence on the system exposes the extension to Tophat.

A good example of this would be Safari extensions, for example. They are installed from the App Store as applications and then provide the extension that they host back to Safari.

There are a few more details in TophatKit's README, but in summary, you must embed your extension in a standalone host application, even if it's just an empty shell.

@luispadron
Copy link
Author

Ah interesting, thank you for the fast info!

I considered that but was confused what the bundle-id for the host application should be given the extension must be com.shopify.Tophat.extension right?

@lfroms
Copy link
Member

lfroms commented Jan 21, 2025

The bundle ID of the extension can be whatever you want, only the EXExtensionPointIdentifier in the extension's Info.plist needs to be com.shopify.Tophat.extension.

The only reason you happen to see the same bundle ID used for the extensions built into Tophat is because they're embedded within Tophat itself, but this not required for external extensions. External extension bundle IDs only need to match the bundle ID of the parent application they are embedded in.

@luispadron
Copy link
Author

luispadron commented Jan 21, 2025

Ah perfect that does seem to get it into the Extensions in settings:

Image

However, it doesn't seem to be enable-able (doesn't show up in Tophat's settings either):

Image

I also found that I could use:

pluginkit -a /path/to/extension.appex

To have it be installed without a hosting application

@luispadron
Copy link
Author

Ah! Got it to show up by adding a static var settings: some View to my extension. Thanks for the help here!

@lfroms
Copy link
Member

lfroms commented Jan 22, 2025

Ah! Got it to show up by adding a static var settings: some View to my extension. Thanks for the help here!

Shouldn't need to add a settings property unless your extension is SettingsProviding and requires a configurable UI. It should show up even without settings, like Tophat Core does.

Glad you have something working!

I also found that I could use:

pluginkit -a /path/to/extension.appex

That also works though it does make it more difficult to actually distribute the extension (potential Gatekeeper or other security issues, I imagine). Though if you can come up with a robust solution that can make this easy to install for your organization, then that's fine too.

@luispadron
Copy link
Author

Right, I think I was missing some conformance to the TophatKit protocols which adding the settings view helped me resolve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants