I'm building a MacOS SwiftUI Document-Based App where I defined a new Exported Type Identifier with a new extension and all of that.
In the beginning, I didn't care about the Type Identifier so I named it com.example.Dapka.dap
, but later on, I tried to get rid of the example
word, changing the identifier to com.Dapka.dap
from Info.plist and Document declaration file, but since then, everytime I try to reopen an autosaved document, it won't open, and I see the following error in the console:
This application can't reopen autosaved com.example.dapka.dap files.
-[NSDocumentController reopenDocumentForURL:withContentsOfURL:display:completionHandler:] failed during state restoration. Here's the error:
Error Domain=NSCocoaErrorDomain Code=256 "The autosaved document “(null)” could not be reopened. Dapka cannot open files in the “Dapka Document” format." UserInfo={NSUnderlyingError=0x600003e5e610 {Error Domain=NSCocoaErrorDomain Code=256 "“Unsaved Dapka Document 5” could not be handled because Dapka cannot open files in the “Dapka Document” format." UserInfo={NSLocalizedDescription=“Unsaved Dapka Document 5” could not be handled because Dapka cannot open files in the “Dapka Document” format., NSLocalizedFailureReason=Dapka cannot open files in the “Dapka Document” format.}}, NSLocalizedDescription=The autosaved document “(null)” could not be reopened. Dapka cannot open files in the “Dapka Document” format., NSLocalizedFailureReason=Dapka cannot open files in the “Dapka Document” format.}
Here is Exported Type Identifier
as shown in info.plist:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.content</string>
</array>
<key>UTTypeDescription</key>
<string>Dapka Document</string>
<key>UTTypeIdentifier</key>
<string>com.Dapka.dap</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>dap</string>
</array>
</dict>
</dict>
</array>
And this is Document Types
as well:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconSystemGenerated</key>
<integer>1</integer>
<key>CFBundleTypeName</key>
<string>Dapka Document</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.Dapka.dap</string>
</array>
<key>NSDocumentClass</key>
<string></string>
<key>NSUbiquitousDocumentUserActivityType</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).dap</string>
</dict>
</array>
And this is the document variable in the Document declaration file:
extension UTType {
static var dapkaDocument = UTType(exportedAs: "com.Dapka.dap")
}
Notice that, when I return the identifier back to com.example.dapka.dap
, everything returns normal. I'm very confused, I think there is still some place that contains the old example
word.