How to add frontend resources for using in package/paclets?

I have some thumbnails that I want to use inside my package, which need to be loaded with FEPrivateFrontEndResource. AFAIK those assets have to be placed in .tr files in this exact directory (on macOS):

/Applications/Mathematica.app/Contents/SystemFiles/FrontEnd/TextResources

Now of course one could manually copy them over on installation, but what if I'm using PacletInstall? What are the best practices here for distribution?

• They should be placed in pacletDirPath/FrontEnd/TextResources/resource.tr. These get added to the resource path automatically by the PacletManager if FrontEnd is set in the extensions. See mathematica.stackexchange.com/a/132065/38205 for more. – b3m2a1 Dec 8 '17 at 5:20
• I believe you have my Qwant service connection installed. You can see how I handled the "SystemResources" equivalent by looking at that via: SystemOpen@PacletFind["*_Qwant"][[1]]["Location"] – b3m2a1 Dec 8 '17 at 5:22
• You can also add them to ~Applications/Your application/FrontEnd/TextResources which is what I do for modifying menus and contextual menus when my application is running – Mike Honeychurch Dec 8 '17 at 6:07

1 Answer

So I tossed this in a comment, but it deserves some elaboration.

The appropriate place is the "FrontEnd/TextResources" subdirectory in your paclet.

You can see how WRI does this by looking at the CloudObject paclet:

PacletFind["CloudObject"][[1]]["Location"] // SystemOpen


You then need to add

{"FrontEnd", Prepend -> True}


As an extension in your PacletInfo.m

Szabolcs has more info here

Finally, all the paclet manager does is add the text resource directories to:

CurrentValue[$FrontEndSession, {PrivatePaths, "TextResources"}]  And in fact you can see this is how the CloudObject system adds its resources: CurrentValue[$FrontEndSession, {PrivatePaths, "TextResources"}][[1]]

FrontEndFileName[{\$UserBaseDirectory, "Paclets", "Repository",
"CloudObject-11.2.1398", "FrontEnd", "TextResources"},
"PacletManager" -> True, "Prepend" -> True]


Thus any arbitrary directory you want to use can be added like that, which gives you a way to dynamically set a directory at paclet loading.