Makefile - Add To The Bottom of your Makefile and change NameOfYourBundle to be the name you wish.
NOTE: It cannot be the same as your TWEAK_NAME
BUNDLE_NAME = NameOfYourBundle
NameOfYourBundle_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
include $(THEOS)/makefiles/bundle.mk
Resources - In the main directory of your tweak add a folder called Resources and place your images inside it.
Code - Create a NSBundle, init with "initWithPath:", get the image path with "pathForResource:", get image with "imageWithContentsOfFile:"
#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/NameOfYourBundle.bundle"
//Get the Bundle
NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];//Get Path to Image
NSString *imagePath = [bundle pathForResource:@"imageName" ofType:@"png"];
//UIImage From File
UIImage *image = [UIImage imageWithContentsOfFile:imageOnePath];
NOTE:The same basic idea also works for other files types, just use the appropriate classes equivalent method
Man, I am following your example, but the image is not getting loaded. I tried to inspect the contents of the /Library/MobileSubstrate/DynamicLibraries path, but the subpath MobileSubstrate/DynamicLibraries does not exists. Should I create the path by myself?
ReplyDeleteThanks in advance.
Yes please answer the above question. I need to know the answer too!
ReplyDeleteOk, so, now it works. What was my problem?: that I mistyped the extension ".bundle" and I had typed ".bund"
DeleteAnother reason was that I pasted a .jpg image in the Resources directory. In code, I was using ofType:@"jpg", while in fact, the resources compiler converts the jpg to png (o.O)
You dont have to create the folders; theos make does it for you.
Good luck m8.