Problems with csv-Import

I want to import a csv-file to my app. It works when I use the Simulator but when I try to import the same file on my iPad, the follwowing message occurs: UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/4C49BACA-5490-45A4-A8DF-6D47711CFC34/File Provider Storage/LUSD 3.csv, NSUnderlyingError=0x2812068e0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}. Where do I find the right settings to enable the import of this csv-file?

Replies

Is that where you are saving the file? It sounds like it is in the bundle and on a real device that will be write protected.

You need to save the file in a write enabled folder. Documents or some where in the Application Data folder, for instance.

  • It doesn't matter if it's in the iCloudDrive or "on my iPad" eg DataFolder. The file itself is read and write enabled. I can't open it when trying on the "real device" but it works with the Simulator. Is there something I have to do with the "entitlements" of the target?

  • The problem is the file is outside your app's container. I've not used that functionality myself.

    https: //useyourloaf.com/blog/accessing-security-scoped-files/

    This goes into how to do it.

Add a Comment

First up, I recommend that you read On File System Permissions. While it’s focused on the Mac, some key concepts apply to iOS as well.

How did you get this URL? If, for example, you get it from one of the standard file UIs, like UIDocumentPickerViewController, the result is a security-scoped URL. To access the file’s contents, you need to call the startAccessingSecurityScopedResource() method. Don’t forget to call the stop method when you’re done.

The blog post referenced by jlilest has a concrete example of this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thanks a lot! Now it works!!!

Add a Comment