7

我用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

但是当我尝试编译时,我得到:

 No rule to make target `obj/image.png.o', needed by `obj/MyTweak.dylib'.  Stop. 

我能做些什么来包括它?

(抱歉语法错误,从 iphone 询问)。

4

2 回答 2

11

MyTweak_FILES 变量应该只包含可以编译的文件。使文件以不同的方式处理资源。

要包含资源,您需要按如下方式创建捆绑包。

1) 在tweak.xm 目录中创建一个名为Resources 的文件夹。

2)将所有资源文件(所有PNG)放入该文件夹中。

3)将以下信息添加到您的制作文件中

BUNDLE_NAME = your_bundle_identifier

your_bundle_identifier_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries

include $(THEOS)/makefiles/bundle.mk

4) 在你的tweak.xm 文件上定义你的包如下。

#define kBundlePath @"/Library/MobileSubstrate/DynamicLibraries/your_bundle_identifier.bundle"

5)您现在可以初始化捆绑包并使用调整中的图像,如下所示:

NSBundle *bundle = [[[NSBundle alloc] initWithPath:kBundlePath] autorelease];

NSString *imagePath = [bundle pathForResource:@"your_image_name" ofType:@"png"];

UIImage *myImage = [UIImage imageWithContentsOfFile:imagePath]

在上述步骤中,将 your_bundle_identifier 替换为您的调整包标识符,该标识符将位于控制文件中。(例如:com.yourdomain.tweak_name)

还将 your_image_name 替换为您要使用的图像的名称。

您几乎可以通过上述方式使用任何资源(例如:声音文件)。

于 2013-05-27T07:20:31.287 回答
0

除了发布的答案之外,通常的做法是将捆绑包放在“/Library/Application Support/”而不是“/Library/MobileSubstrate/DynamicLibraries/”中

于 2017-03-30T15:24:12.493 回答