App Intents and the Document App Xcode Template

I’m working on an app that deals with a list of text items, so I started with the document app template in Xcode.

I have the app basically doing what I want it to do, but I want to be a good ecosystem citizen, so I’d like to conform to app intents. I think that app intents will able to do what I want - accepting text and passing it back out - but I can’t figure out how to access the document outside of my content view and associated subviews.

Any guidance would be appreciated.

Thank you, Don Carlile

After I wrote the post above, I did extensive research. I read Apple’s documentation and quite a few web pages on the topic of App Intents and SwiftUI.

This led me to refactor my app, pulling a couple of vars and a method out of the view, and putting them into model. On the advice of one site, I have chosen the document as the model. This leaves me with one, hopefully not intractable, problem. How do I reference the document from the App Entity and App Intent?

This is not as easy as it might seem. The app is based on the SwiftUI Document Template. As such, the document is created inside the body of the App. The statements called out by the Apple documentation will not work in that environment. So, how do I connect up the document with the App Entity?

Thanks, Don Carlile

App Intents and the Document App Xcode Template
 
 
Q