I am trying to make a tweak which uses plist file to save some data.
But the app crashes during launch.
Tweak.xm:
#define hackBundlePath @"/Library/MobileSubstrate/DynamicLibraries/testBundle.bundle"
NSMutableDictionary *modsDict = [[NSMutableDictionary alloc] init];
%ctor {
NSBundle *bundle = [[NSBundle alloc] initWithPath:hackBundlePath];
NSString *path = [bundle pathForResource:@"HackData" ofType:@"plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath: path]) {
modsDict = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
}
else {
[modsDict setObject:FALSE forKey:@"test"];
[modsDict setObject:FALSE forKey:@"test1"];
[modsDict setObject:FALSE forKey:@"test2"];
[modsDict writeToFile:[bundle bundlePath] atomically: TRUE];
}
}
Makefile:
include theos/makefiles/common.mk
TWEAK_NAME = test
test_FILES = Tweak.xm ModsTableViewController.mm
test_FRAMEWORKS = Foundation UIKit CoreFoundation
include $(THEOS_MAKE_PATH)/tweak.mk
BUNDLE_NAME = testBundle
testBundle_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
include $(THEOS)/makefiles/bundle.mk
The bundle is created at the right location, but after launching the app it seems that the plist file is not created. So I guess I could say the problem should be at the writeToFile
method or before it