No, you don't need to write the data as a file to your the app’s document directory. With UIActivityViewController, you can share a piece of text, as shown in the following code example let text = This is a piece of text. let activityViewController = UIActivityViewController(activityItems: [text], applicationActivities: nil) With that, when activityViewController is presented, it shows the system-provided share UI that contains a Save to Files button, which allows you to save the text as a file to iCloud Drive. Tapping the button shows a UI that has a Save as field for you to input the file name for the taget file. To import a file, consider using SwiftUI fileImporter. Best, —— Ziqiao Chen Worldwide Developer Relations.
Topic:
UI Frameworks
SubTopic:
SwiftUI