I\'m trying to associate an SQLite3 database file with our app so that it\'s easy to open backed up database from an email. The following however does not seem to work as Ma
For completeness and possibly my own reference later here is a bit of the further details that got it working for me:
Declaring Document Types your app supports (eg sqlite3 databases)
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.company.sqlite3.database</string>
<key>UTTypeReferenceURL</key>
<string>http://www.company.com/</string>
<key>UTTypeDescription</key>
<string>MyCompany SQLite Database</string>
<key>UTTypeIconFile</key>
<array>
<string>Icon-Small.png</string>
<string>Icon.png</string>
</array>
<key>UTTypeConformsTo</key>
<array>
<string>public.database</string>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>sqlite</string>
</array>
<key>public.mime-type</key>
<array>
<string>application/x-sqlite3</string>
<string>application/octet-stream</string>
</array>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>MyCompany SQLite Database</string>
<key>CFBundleTypeIconFiles</key>
<array>
<string>Icon-Small.png</string>
<string>Icon.png</string>
</array>
<key>CFBundleTypeExtensions</key>
<array>
<string>sqlite</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/x-sqlite3</string>
<string>application/octet-stream</string>
</array>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>com.company.sqlite3.database</string>
</array>
<key>NSPersistentStoreTypeKey</key>
<string>SQLite</string>
</dict>
</array>
Copy paste the above XML into your Info.plist file.
Setting the 'Store Type' to 'SQLite' didn't wasn't the killer fix for me.
My previous post here mentioned a rather incorrect way of getting it to work which accepts all files and didn't properly export the type.
Also if your app is emailing off these files as attachments make sure it matches the MIME type you set it to capture. The application/octet-stream is not important it is just that older versions of our app are emailing out the databases with that MIME type.
eg,
[controller addAttachmentData:[NSData dataWithContentsOfFile:dbPath] mimeType:@"application/x-sqlite3" fileName:filename];
I sure hope anyone else that tries to find out how to get their app to support opening sqlite3 database backups finds this helpful.
As per Apple's documentation, CFBundleDocumentTypes is an array, not a dict.
You have:
<key>CFBundleDocumentTypes</key>
<dict>
so the <dict> needs to be in an <array> element, like so:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>App Database</string>
<!-- ... -->
</dict>
</array>
Okay I've sorted this out. If you instead use 'target's info' panel and add your document type there (and then select 'SQLite' as the type') it just works. Obviously provided you've exported the type as above.