What is the UTType for CSS files?

I am trying to use the Xamarin.Essentials FilePicker to let the user select a CSS file. My code:

Code Block
var customFileType =
new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
{
{DevicePlatform.macOS, new[] {"css"} }
});
var pickResult = await FilePicker.PickAsync(new PickOptions
{
FileTypes = customFileType,
PickerTitle = "Select stylesheet to install"
});


The above works fine when I build for MacOS platform. I am also trying to add a entry there for DevicePlatform.iOS but I do not know the string to pass for a CSS file or it's UTType. I found one for HTML but not CSS.

Thanks.



Accepted Reply

What is the UTType for CSS files?

The correct type is public.css.

One easy way to work this out is with the shiny new UniformTypeIdentifiers framework:

Code Block
let tQ = UTType(filenameExtension: "css")
print(tQ)
// prints: Optional(<UTType 0x109149770> public.css)


You don’t want to do that at runtime (see the Warning box in the docs) but you can build a tiny little tool that runs this code on your Mac.

Share and Enjoy

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

Replies

What is the UTType for CSS files?

The correct type is public.css.

One easy way to work this out is with the shiny new UniformTypeIdentifiers framework:

Code Block
let tQ = UTType(filenameExtension: "css")
print(tQ)
// prints: Optional(<UTType 0x109149770> public.css)


You don’t want to do that at runtime (see the Warning box in the docs) but you can build a tiny little tool that runs this code on your Mac.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks. I managed to add the required resources with this UTType value. Sorted. 😀