Why is there no UTI for gltf/glb/metallib files?

I need to be able to drop these onto my app kram. But using the UTType library reports the following:

metallib - "application/octet-stream"
gltf - "model/gltf+json",
glb - "model/gltf+binary"

 [UTType typeWithFilenameExtension: @"metallib"].identifier,  
 [UTType typeWithFilenameExtension: @"gltf"].identifier,
 [UTType typeWithFilenameExtension: @"glb"].identifier

dyn.ah62d4rv4ge8043pyqf0g24pc, // ick - metallib
dyn.ah62d4rv4ge80s5dyq2,    // ick - gltf
dyn.ah62d4rv4ge80s5dc     // ick - glb
 ```


Replies

Also when I specify pasteboardOptions, then folder drops stop working. I need to be able to drop files and folders. Are there any modern samples of using the clipboard? The docs Apple publishes on clipboard handling are from 2010.


NSArray<NSString *>* pasteboardTypes = @[
  // don't really want generic urls, but need folders to drop
  //NSPasteboardTypeURL
   
  // this is preventing folder drops ?
  NSPasteboardTypeFileURL
];

 // added for drag-drop support
  [self registerForDraggedTypes:pasteboardTypes];

// ktx, ktx2, png, and dds for images
// zip, metallib
// gltf, glb files for models
NSArray<NSString*>* utis = @[
 [UTType typeWithFilenameExtension: @"png"].identifier,
 [UTType typeWithFilenameExtension: @"ktx"].identifier,
 [UTType typeWithFilenameExtension: @"ktx2"].identifier,
 [UTType typeWithFilenameExtension: @"dds"].identifier,
  
 [UTType typeWithFilenameExtension: @"zip"].identifier,
 [UTType typeWithFilenameExtension: @"metallib"].identifier,
  
#if USE_GLTF
 [UTType typeWithFilenameExtension: @"gltf"].identifier,
 [UTType typeWithFilenameExtension: @"glb"].identifier
 //@"model/gltf+json",
 //@"model/gltf+binary"
#endif
];
NSDictionary* pasteboardOptions = @{
  // This means only these uti can be droped.
  NSPasteboardURLReadingContentsConformToTypesKey: utis
   
  // Don't use this it prevents folder urls ?
  //, NSPasteboardURLReadingFileURLsOnlyKey: @YES
};

  - (NSDragOperation)draggingEntered:(id)sender
{
  if (([sender draggingSourceOperationMask] & NSDragOperationGeneric) ==
    NSDragOperationGeneric) {
    NSPasteboard* pasteboard = [sender draggingPasteboard];
     
    bool canReadPasteboardObjects =
      [pasteboard canReadObjectForClasses:@[ [NSURL class] ]
                    options:pasteboardOptions];

    // when this fails, toss the pasteboardOptions
    // like when I drag folders
    if (!canReadPasteboardObjects) {
      canReadPasteboardObjects =
        [pasteboard canReadObjectForClasses:@[ [NSURL class] ]
                    options:@{}];
    }
    // don't copy dropped item, want to alias large files on disk without that
    if (canReadPasteboardObjects) {
      return NSDragOperationGeneric;
    }
  }

  // not a drag we can use
  return NSDragOperationNone;
}

Fixed the missing drop of folder by adding "public.directory" to the list of UTI array. Still missing glb/gltf UTI in this library. These are older than usd/usb files, so seems like they should be in there.