I made a fully functional tweak with theos and I need to use an image file in it , the code for getting the image is correct (tested on Xcode) . but the image isn't included in the final DEB file .
and I have this makefile :
SDKVERSION=6.0
include theos/makefiles/common.mk
include theos/makefiles/tweak.mk
TWEAK_NAME = MyTweak
MyTweak_FRAMEWORKS = Foundation CoreGraphics UIKit
MyTweak_FILES = Tweak.xm image.png
include $(THEOS_MAKE_PATH)/tweak.mk
But when I try to compile I get :
No rule to make target `obj/image.png.o', needed by `obj/MyTweak.dylib'. Stop.
what can I do to include it ??
(Sorry for bad syntax , asking from iphone).
MyTweak_FILES variable should only include files that can be compiled. Make file handles resources differently.
To include resources you need to create a bundle as follows.
1) Create a folder called Resources in the tweak.xm directory.
2) Put all your resource files (all your PNG's) into that folder.
3) Add the following info to your make file
BUNDLE_NAME = your_bundle_identifier
your_bundle_identifier_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
include $(THEOS)/makefiles/bundle.mk
4) Define your bundle as follows on top of your tweak.xm file.
#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/your_bundle_identifier.bundle"
5) You can now initialize the bundle and use the images within your tweak as follows:
NSBundle *bundle = [[[NSBundle alloc] initWithPath:kBundlePath] autorelease];
NSString *imagePath = [bundle pathForResource:@"your_image_name" ofType:@"png"];
UIImage *myImage = [UIImage imageWithContentsOfFile:imagePath]
In the above steps replace your_bundle_identifier with your tweaks bundle identifier which would be in the control file. (ex: com.yourdomain.tweak_name)
Also replace your_image_name with the name of the image you want to use.
You can pretty much use any resources (ex: sound files) the above way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With