use*_*069 7 makefile include theos
我用theos做了一个功能齐全的调整,我需要在其中使用一个图像文件,获取图像的代码是正确的(在Xcode上测试).但图像不包含在最终的DEB文件中.
我有这个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
Run Code Online (Sandbox Code Playgroud)
但是当我尝试编译时,我得到:
No rule to make target `obj/image.png.o', needed by `obj/MyTweak.dylib'. Stop.
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能包括它?
(抱歉语法错误,从iphone询问).
这不是你使用theos包含资源的方式.MyTweak_FILES变量应该只包含可以编译的文件.使文件处理资源的方式不同
要包含创建捆绑包所需的资源,如下所示.
1)在tweak.xm目录中创建一个名为Resources的文件夹.
2)将所有资源文件(所有PNG)放入该文件夹.
3)将以下信息添加到您的make文件中
BUNDLE_NAME = your_bundle_identifier
your_bundle_identifier_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
include $(THEOS)/makefiles/bundle.mk
Run Code Online (Sandbox Code Playgroud)
4)在tweak.xm文件的顶部按如下方式定义包.
#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/your_bundle_identifier.bundle"
Run Code Online (Sandbox Code Playgroud)
5)您现在可以初始化捆绑包并使用调整中的图像,如下所示:
NSBundle *bundle = [[[NSBundle alloc] initWithPath:kBundlePath] autorelease];
NSString *imagePath = [bundle pathForResource:@"your_image_name" ofType:@"png"];
UIImage *myImage = [UIImage imageWithContentsOfFile:imagePath]
Run Code Online (Sandbox Code Playgroud)
在上面的步骤中,将your_bundle_identifier替换为调整包标识符,该标识符将位于控制文件中.(例如:com.yourdomain.tweak_name)
还要将your_image_name替换为要使用的图像的名称.
您可以通过上述方式使用任何资源(例如:声音文件).