fileAssociations cannot register an app for an existing UTI such as Markdown

Author: francipCreated Sep 9, 2026Updated Sep 9, 2026

Summary

app.fileAssociations always creates and exports an app-specific UTI from the bundle identifier plus extension. That works for novel/private formats, but it prevents an app from registering as an editor for an existing type such as Markdown.

For .md, macOS identifies existing files as net.daringfireball.markdown. An Electrobun app configured with ext: ["md"] instead claims (for example) dev.example.markdown-uti-repro.md, so NSWorkspace.urlsForApplications(toOpen:) does not include the app and Finder does not offer it under Open With.

Standalone repro

https://gist.github.com/francip/0a9f6c7b06f6b4218fc2d877e5b3dd07

Clone the gist, then run:

bash
bun install
bun run build

APP="$PWD/build/dev-macos-arm64/MarkdownUTIRepro-dev.app"
PLIST="$APP/Contents/Info.plist"
/usr/libexec/PlistBuddy -c 'Print :CFBundleDocumentTypes' "$PLIST"
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f "$APP"
printf '# markdown\n' > /tmp/electrobun-uti-repro.md
mdls -name kMDItemContentType -name kMDItemContentTypeTree /tmp/electrobun-uti-repro.md
swift -e 'import AppKit; let u = URL(fileURLWithPath: "/tmp/electrobun-uti-repro.md"); print(NSWorkspace.shared.urlsForApplications(toOpen: u).map(\.path).filter { $0.contains("MarkdownUTIRepro") })'

Actual result

The app's document type references dev.example.markdown-uti-repro.md and exports that type as conforming to public.data. mdls reports the file as net.daringfireball.markdown, and the final command prints [].

Expected result

The configuration API should allow an association to reference an existing UTI instead of always exporting a new one. For example, an optional uti: "net.daringfireball.markdown" could cause CFBundleDocumentTypes[].LSItemContentTypes to use that value and add an UTImportedTypeDeclarations entry rather than UTExportedTypeDeclarations.

For formats that do need a new UTI, exposing conformance and tag metadata would also let an app declare a more precise type than public.data.

Environment

  • Electrobun 2.0.2-beta.17
  • Bun 1.4.0
  • macOS 26.6.2, arm64

As a local verification, post-processing the generated plist to reference/import net.daringfireball.markdown makes the same app appear in NSWorkspace.urlsForApplications(toOpen:) immediately.