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

HBPreferences does not work in Sandbox app (Dopamine 2.0.11 rootless Jailbreak) #64

Open
NaohikoKubo opened this issue Apr 7, 2024 · 1 comment

Comments

@NaohikoKubo
Copy link

I am developing a Tweak with 'com.apple.corelocation' as the bundle filter.

My environment is as follows:

  • iPhone XS Max
  • iOS 15.1
  • Dopamine 2.0.11 rootless Jailbreak

I want to share settings between multiple apps (more precisely, between my Tweaks associated with each app) and am considering using HBPreferences for this purpose.

However, Read/Write operations with HBPreferences do not function correctly from Tweak apps tied to Sandbox apps.

As a sample implementation, I tried implementing simple settings read and write as follows:

preferences = [[HBPreferences alloc] initWithIdentifier:@"com.test.myapp"];
[preferences setObject:[NSString stringWithFormat:@"%.2f", 100.0] forKey:@"speed"];
double speed = [preferences doubleForKey:@"speed" default:1.0];

With the exact same implementation,
For instance, when the Tweak is linked to jailbreak apps like Filza or Sileo, or a jailbreak settings app I created, doubleForKey and setObject can correctly perform read and write operations.

However, when the Tweak is linked to apps downloaded from the App Store, despite the settings values being present in com.test.myapp.plist, doubleForKey always retrieves the default value, and setObject is also ignored.

Is this behavior as per the specifications? Or is there any potential workaround?

@noxrim
Copy link

noxrim commented Oct 18, 2024

I just had this exact same issue, here's the workaround I came up with:

NSDictionary* preferences = [NSDictionary dictionaryWithContentsOfFile:
  [NSString stringWithFormat:
    @"%s/var/mobile/Library/Preferences/your.tweak.domain.plist",
    THEOS_PACKAGE_INSTALL_PREFIX
  ]
];
if (preferences == nil) preferences = [NSDictionary dictionary];

//then just read keys from the NSDictionary

This assumes you're building with Theos which will automatically define THEOS_PACKAGE_INSTALL_PREFIX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants