0

I know that if we do not gave permission to user with Supports opening documents in place in iOS, user cannot get access to file or folder created with app and it would stay unreachable to user and private to Developer, the code that I am using in iOS is like this one:

let fileName = "sample"
let documentDirectoryUrl = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let fileUrl = documentDirectoryUrl.appendingPathComponent(fileName).appendingPathExtension("txt")

How ever using this code in macOS would expose our file or data to user! Which I would like keep it private. I am not looking to make it hidden, I am looking to make it impossible to access from user side. How can I do this in macOS?

ios coder
  • 1
  • 4
  • 31
  • 91
  • 1
    "user cannot get access to file or folder created with app and it would stay unreachable to user and private to Developer," This is not true. There is no way to put data on a user's phone (or any other device they control) that they cannot access if they choose to. It's slightly more difficult on iOS than on Mac, but the problem is identical. – Rob Napier Jan 20 '22 at 15:01
  • Maybe encrypt the file and/or store it in a binary format. – Joakim Danielson Jan 20 '22 at 15:06
  • @JoakimDanielson: So basically you say it does not matter if the file or data exposed, the important thing is being encrypted or binary, I am not storing sensitive data, I am storing some setting for app, would be binary a good choice? any link about the best approach? – ios coder Jan 20 '22 at 15:43
  • @RobNapier: I got confused with your comment, as long as I tested in real device or simulator on iOS platform, the user cannot access or see the file or folder of my app unless I gave the permission in plist, you said it is not True, can you explain how would you be able see and access file sample.txt as user if you where using my app? – ios coder Jan 20 '22 at 15:44
  • If the app can read a file then the user can read the same file outside of the app. If you are specifically looking at setting preferences, you should be using `UserDefaults`. – Rudedog Jan 20 '22 at 16:48
  • (1) Jailbreak the device. Copy the file off. Read it. Or (2) Backup device locally or to iCloud. Use a backup extractor. Read it. It's a little harder than on a Mac, but it's not a huge deal. The user controls the device. There's nowhere to hide things from them on their own device. – Rob Napier Jan 20 '22 at 17:50
  • For more on this general problem, see https://stackoverflow.com/questions/9181186/secure-https-encryption-for-iphone-app-to-webpage and the links there. For discussion of obfuscation techniques you can use (and their limits), see https://chariotsolutions.com/screencast/philly-ete-2020-rob-napier-secrets-and-lies/ – Rob Napier Jan 20 '22 at 17:58
  • @RobNapier: Thanks, for info. – ios coder Jan 20 '22 at 20:43

0 Answers0