Search code examples
ioscocoa-touchuidocumentbrowservc

How do I specify a file type for importing .obj files?


I'm trying to get my app to recognize .obj files for importing.

I've tried to follow the instructions in this WWDC video.

I've tried specifying as both an Imported UTI, and an Exported UTI. Neither causes the file to be openable in UIDocumentBrowserViewController (the document icon is grayed). I don't understand how my native document format is openable in the browser either. I've tried deleting and reinstalling the app from the device.

What am I missing? Why isn't this simple?

Here's what I've got:

Xcode Document Types


Solution

  • It turns out iOS already knows about .obj files. On macOS, I ran the following:

    mdls myfile.obj

    Which among other things shows:

    kMDItemContentType                 = "public.geometry-definition-format"
    kMDItemContentTypeTree             = (
        "public.content",
        "public.geometry-definition-format",
        "public.text",
        "public.data",
        "public.item",
        "public.3d-content"
    )
    

    So the UTI is public.geometry-definition-format. I don't know if that already specifies the extension or is a more generic type.

    The following worked to make the files openable in UIDocumentBrowserViewController:

    enter image description here

    The UTI isn't declared in the documentation (what a surprise!), so I'd recommend using mdls to look up UTIs.