narner
narner

Reputation: 3221

Adding file icon to custom file type in Xcode

I'm trying to add an icon (a PNG named "FileIcon") to a custom file type in Xcode 13, but can't seem to actually add it via the interface in Xcode:

enter image description here

Any other way to do this?

enter image description here

enter image description here

enter image description here

Upvotes: 2

Views: 1549

Answers (2)

SAHM
SAHM

Reputation: 4179

For a new document of content type public.data, removing the icon filename entry altogether and changing the content type identifier to com.my_company.my_app_name.my_doc_extension.data solved the problem for me. In order for this to work properly, the changes had to be made in the Target's Info panel in Xcode, then the project cleaned and rebuilt, and the app deleted and reinstalled on the device. Deleting the icon information and adding the .data to the identifier were the things that fixed the problem for me.

Upvotes: 0

Brianna Doubt
Brianna Doubt

Reputation: 699

Per Apple's article Setting Up a Document Browser App, there is a snippet in there for the plist:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array/>
        <key>CFBundleTypeName</key>
        <string>Text</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.data</string>
        </array>
    </dict>
</array>

Is this set up correctly in your plist?

Upvotes: 1

Related Questions