【发布时间】:2013-04-30 23:39:54
【问题描述】:
我有一个应用程序链接到的静态库。库代码打开应用程序包中的包中的文件,打开方式如下:
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"Config" ofType:@"plist"];
这工作正常。
但是我想在库中添加一些单元测试代码,所以我有一个逻辑测试目标。由于该文件在应用程序的包中,而不是在静态库的包中,因此我复制了Config.plist 文件并通过Copy Bundle Resources 将其添加到测试代码目标中。但是,当我执行测试代码时,找不到该文件。这是为什么呢?
鉴于以上内容令人困惑,这里是工作区结构的摘要。
Workspace contains:
Application Project with application target, which contains (X)
Config.plist (a)
Library project which contains:
Library target, which contains:
the code opening the file in the bundle (b)
Test library target, which contains: (Y)
A Copy of the Config.plist (c)
因此,如果我构建 X,那么当 b 运行时它可以找到 a。但是当我在运行时构建 Y 时,b 找不到 c。
【问题讨论】:
标签: ios objective-c xcode nsbundle