very interesting. thank you very much @Sarah. But now I have other questions:
you say:
so, Why in Apple documentation you can see that there are many UIT, like:
static var html: UTType {get}
static var javaScript: UTType { get }
static var phpScript: UTType { get }
static var swiftSource: UTType { get }
and so on.
a clarification must be made, however: about CSS or Java files, there isn’t UIT
but the question is: if all of this the base type is Text, why there are so many file type (the question is valid also for audio and image)? and, as you can see, What I need to do for file type that there aren’t in UIT like CSS?
Let’s go to the practical, so this post can also help others like me who want to make a document-based app in AppKit and not SwiftUI.
In the AppKit template, as you know, it has three sections:
- Document Type
- Exported Type
- Imported Type

the Apple documentation reads: "When defining a type, you need to define it as an exported or imported type; this declaration indicates whether your app is the source of the type or if it supports using a type defined elsewhere, respectively. If your app uses a type that this framework provides, don’t redeclare it in your app’s bundle.
Define an exported type when your app is the canonical source of information for that type. For example, an app that uses its own proprietary document format should declare it as an exported type.
Define an imported type if your app uses a type that another app defines or if it’s a proprietary file format the system doesn’t declare. When importing a type from another app, don’t declare your own identifier; instead, use the same type identifier as the original. "
based on this, to make my app handle a custom file type (webcodeproj), and several existing types (HTML, CSS Javascript, PHP, Java, Swift and so on) what should I do in practice?
because I tried to add an imported type for Css which, according to the Apple forum, should conform to public.css,
I also put it in the Document Type, but when I open the dialog to open the files and look for a css file, this is not selectable. so how can I correctly set all this kind of files?
Last question: as you said, the read and write methods are empty and the only thing they do is throw the error. what should I write about it?
in the apple documentation the methods are implemented like this:
override func read(from data: Data, ofType typeName: String) throws {
content.read(from: data)
}
override func data(ofType typeName: String) throws -> Data {
return content.data()!
}
but does this apply to all types of files? or only applies to text types? but also in the case of text types, does it apply to any type of text?
p.s.
It’s a real shame that the book (MacOS by Tutorial) was made for SwiftUI and not AppKit. it would have been much more useful since, as you said yourself, Appkit doesn’t change often. It would have been much more useful to me.
Anyway, thank you very much for your patience