0

I have a plist file at: /var/mobile But it seems that my mobilesubtrate tweak does not read anything from the plist file.

This is my code:

   NSString *path = @"/var/mobile/test.plist";
   self.mods = [NSMutableDictionary dictionaryWithContentsOfFile:path];

self.mods.count returns 0, and the entire dictionary is empty. The plist file does have 3 key/value pairs.

I found a crash report log on my phone, it said this

Sandbox Violation: minecraftpe deny file-read-metadata /private/var/mobile/test.plist

I guess the tweak is still sandboxed and can't access files outside the app?

junyi00
  • 792
  • 3
  • 8
  • 28
  • Does [Can't find /var/mobile/Applications directory for iOS documents](http://stackoverflow.com/q/9014406) help? – jscs Jul 25 '14 at 18:43
  • Don't see how that can help me. The problem is that, the file in my phone exists and I can access it, but my tweak can't read it for some reason – junyi00 Jul 25 '14 at 18:44
  • I would firstly make sure that the plist has valid formatting etc by doing a validation: open terminal ant type plutil and see if you get any formatting errors. – Danny S Jul 25 '14 at 18:47
  • You're trying both strictly on the device, not in the simulator? – jscs Jul 25 '14 at 18:48
  • @DanSpag No problem at all – junyi00 Jul 25 '14 at 18:50
  • @JoshCaswell On the device, not in the simulator – junyi00 Jul 25 '14 at 18:51
  • Return Value -- A new dictionary that contains the dictionary at path, **or nil if there is a file error or if the contents of the file are an invalid representation of a dictionary**. – Hot Licks Jul 25 '14 at 18:52
  • 2
    I'd suggest you open the file with some operation that has an `error:` parameter, and see what is reported. – Hot Licks Jul 25 '14 at 18:55
  • Is the plist root a dictionary? As you may know it could be either Dictionary or Array. – Danny S Jul 25 '14 at 19:20
  • 1
    Simplest would probably be [NSString `stringWithContentsOfFile:encoding:error:`](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/clm/NSString/stringWithContentsOfFile:encoding:error:). You could NSLog the resulting NSString to observe the data actually read from the file. – Hot Licks Jul 25 '14 at 19:34
  • @DanSpag The plist root is dictionary – junyi00 Jul 25 '14 at 20:01
  • @HotLicks I will try to do so tomorrow – junyi00 Jul 25 '14 at 20:43
  • (The encoding should generally be NSUTF8Encoding or whatever it's called.) – Hot Licks Jul 25 '14 at 20:44
  • I found the problem, I have updated my question – junyi00 Jul 25 '14 at 20:59

1 Answers1

0

AppStore apps are sandboxed. Tweaks are code that run within the process that the filter specifies. Apps have a process in which the tweaks are injected, therefore they have the same limitations.

You can however read from /User/Library/Preferences/com.your.tweak.preferences.plist by using the NSUserDefaults class. If you need other types of files you could look into using sandcastle to escape the sandbox and get the files from elsewhere.

uroboro
  • 291
  • 2
  • 6