Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NSUserDefaults are not written to App's respective directories #149

Open
hugeBlack opened this issue Sep 2, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@hugeBlack
Copy link
Collaborator

hugeBlack commented Sep 2, 2024

Describe the bug

I found that although apps write almost all their files to their respective folders, their NSUserDefaults are still written to LiveContainer's Library/Preferences, which creates a mess in that folder and is hard for users to move apps to other devices.
I wander if it's possible to redirect NSUserDefaults writes to some folder in Document?

Instructions to reproduce

Install any app that uses NSUserDefaults and check LiveContainer's Library/Preferences

What version of LiveContainer are you using?

2.1.2

Other info

I dumped symbols of NSUserDefaults class and didn't find any way to set a path. I wonder if it's hard coded into that class, or it uses a different environment variable other than HOME?
I also tried to create a symlink but iOS didn't allow any write to Library/Preferences folder it self.

There is a method caller -[NSUserDefaults _initWithSuiteName:container:] but it seems that not all NSUserDefaults are instantiated by this method.

@hugeBlack hugeBlack added the bug Something isn't working label Sep 2, 2024
@hugeBlack
Copy link
Collaborator Author

I found a method -[NSUserDefaults _container] that I can hook to redirect most NSUserDefaults write to other location, but some still write directly to Library/Preferences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant