danielsaidi / DocumentKit

DocumentKit is a Swift SDK that adds more capabilities to DocumentGroup-based apps in SwiftUI.
MIT License
62 stars 3 forks source link

Demo fails to create document #4

Open easiwriter opened 1 month ago

easiwriter commented 1 month ago

This is just the stuff I was looking for. Unfortunately I can't get it to create a new document, either in the Demo or in my App. The problem is in Apple's document app code because the Document Template app fails the same way. I've tried it with Xcode 15.4 and the latest beta. I've attached the error message.

Screenshot 2024-07-21 at 09 46 20
danielsaidi commented 1 month ago

Hi @easiwriter

I think you must register the file extension with a custom uniform type within the app to signal that you know how to handle the UtType.

easiwriter commented 1 month ago

Thanks for the fast response, and on a Sunday! I don't think it's that because Apple's Document App Template registers one and it too fails!

I've filed bug report FB14419530

danielsaidi commented 1 month ago

I'm on vacation, so I don't have the source code with me. Is the .exampletext extension set by the app or by you? Document-based apps will only (to my knowledge) open known document types, so if this is a custom extension, the app needs to tie it together with a uniform type identifier.

But I will keep this issue open to make the demo and the docs mention custom file extensions in more detail 👍

easiwriter commented 1 month ago

I've just tried the Demo on Xcode 16.0 beta 3. If you run it on an IOS 18 sim you get the (horrible) result below, which has screwed up the DocumentKit Toolbar. It's OK on an IOS 17 sim (with Xcode beta)

Screenshot 2024-07-21 at 10 35 44
danielsaidi commented 1 month ago

@easiwriter Thank you for notifying me. iOS 18 adds a bunch of stuff to the DocumentGroup that I haven't tested yet. Would you mind creating this as a separate issue?

easiwriter commented 1 month ago

The Document Template app creates a UTType extension as shown below:

struct TestDocumentAppApp: App {
    var body: some Scene {
        DocumentGroup(editing: .itemDocument, migrationPlan: TestDocumentAppMigrationPlan.self) {
            ContentView()
        }
    }
}

extension UTType {
    static var itemDocument: UTType {
        UTType(importedAs: "com.example.item-document")
    }
}

I've created a new issue for the IOS 18 stuff.

I am fed up with Apple moving the goal posts. I've been building an App for the past several years and trying to keep up. I successfully moved to SwiftUI and have tried 3 times, unsuccessfully, to move to SwiftData.

Enjoy your vacation!

danielsaidi commented 1 month ago

Thank you for the additional information! I will have a look at this later, closer to the release of iOS 18.

easiwriter commented 1 month ago

it all works ok if compiled with Xcode 15.4 and run on an IOS 17 sim