1

I need to save a file to the main app's documents directory from my action extension. Is this possible? If so how should I go about it? I have noticed that the path given by the code below is different when called from the main app and the the extension.

NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]

I found help from "Sharing data between an iOS 8 share extension and main app" on how to share user defaults. But document directory is still a mystery to me.

ThE uSeFuL
  • 1,456
  • 1
  • 16
  • 29
  • 1
    I found a solution. Since this was mistakenly marked as an duplicate, I'm forced to post my answer as a comment. Answer: You cannot access the main app's document directory from an extension. Approach should be to use the group container to store all your shared documents. Apple reference https://developer.apple.com/documentation/foundation/nsfilemanager/1412643-containerurlforsecurityapplicati – ThE uSeFuL Oct 31 '18 at 17:13

0 Answers0