Custom extension file not opening in iMessage Custom extension file not opening in iMessage ios ios

Custom extension file not opening in iMessage


This answer is correct in that the custom document can be opened from Messages if it conforms to public.text. The drawback to this solution is that the document is previewed as raw text, which might not be the desired result.

Documents conforming to public.data can be opened from the Messages app without being previewed as raw text by creating a Quick Look Preview Extension. There isn't much documentation about how to build a Quick Look Preview Extension, but it's pretty straightforward:

  1. In Xcode, choose, File > New > Target.

  2. Choose Quick Look Preview Extension, give your extension a name, and click Finish.

  3. In the info.plist for the newly created extension, add a new item under NSExtension > NSExtensionAttributes > QLSupportedContentTypes, and set the value for this item to your app's custom document type. For example:

    ...<key>NSExtension</key><dict>    <key>NSExtensionAttributes</key>    <dict>        <key>QLSupportedContentTypes</key>        <array>            <string>com.company.abc.wd</string>        </array>        <key>QLSupportsSearchableItems</key>        <true/>    </dict>    <key>NSExtensionMainStoryboard</key>    <string>MainInterface</string>    <key>NSExtensionPointIdentifier</key>    <string>com.apple.quicklook.preview</string></dict>...
  4. Use MainInterface.storyboard and PreviewViewController to define the layout of your custom Quick Look preview. More specifically, read data from the URL provided in the preparePreviewOfFile function and populate the ViewController accordingly. A brief example (in Swift 4):

    func preparePreviewOfFile(at url: URL, completionHandler handler: @escaping (Error?) -> Void) {    do {        let documentData = try Data(contentsOf: url)        // Populate the ViewController with a preview of the document.        handler(nil)    } catch let error {        handler(error)    }}

Some pitfalls I ran into when creating my extension:

  • The exported UTI identifier had to be all lower case. When some of the characters were upper case, the Quick Look preview was never shown, even though I used the same capitalization in my Quick Look Preview Extension.

  • Quick Look Preview Extensions are not allowed to link against dynamic libraries. If a dynamic library is linked, the Quick Look preview will not load.

  • The Quick Look ViewController is not allowed to have any buttons. If it contains a button, the Quick Look preview will not load.

Additional resources:


I came across this post while searching for a similar solution. I was able to email custom files from my app and open it in email or use it with AirDrop. If I sent it via iMessage it even showed up with my custom icon, but when I tapped it in iMessage nothing happened.

Be aware that you need something like the following in your plist file (from How do I associate file types with an iPhone application?)

<key>UTExportedTypeDeclarations</key><array>    <dict>        <key>UTTypeConformsTo</key>    <array>        <string>public.plain-text</string>        <string>public.text</string>    </array>    <key>UTTypeDescription</key>    <string>Molecules Structure File</string>    <key>UTTypeIdentifier</key>    <string>com.sunsetlakesoftware.molecules.pdb</string>    <key>UTTypeTagSpecification</key>    <dict>        <key>public.filename-extension</key>        <string>pdb</string>        <key>public.mime-type</key>        <string>chemical/x-pdb</string>    </dict></dict>

NOTE: I had something very similar for my app BUT in the UTTypeConformsTo I only had public.data since my files are zipped data files.

I found that by adding public.text as a second item in the array it would be actionable in iMessage. On a further note, if I added public.plain-text as a third item my file ended up with a Pages icon instead of my icon (so I removed it)

I hope this helps someone. It's taken me hours to get to the bottom of it.


The value in your Info.plist for the LSItemContentTypes key should equal what is declared by your Meeting object.

Presumably your Meeting object adheres to the UIActivityItemSource protocol. Make sure the value you return (from the delegate method activityViewController:dataTypeIdentifierForActivityType:) matches the value you have declared as readable in your Info.plist.