【问题标题】:Unit Testing Target not recognizing static csv file单元测试目标无法识别静态 csv 文件
【发布时间】:2012-10-03 02:37:08
【问题描述】:

我正在运行 Xcode 4.5,并且已将新的单元测试目标添加到现有项目中。

我在目标的Copy Bundle Resources 部分添加了一个 csv 文件,但目标没有将该文件识别为捆绑包的一部分。当我在 LLDB 中运行以下命令时,我得到 nil 结果:

po [NSBundle mainBundle]
(id) $2 = 0x01937180 NSBundle </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/Developer/usr/bin> (loaded)

po [[NSBundle mainBundle] pathForResource:@"myFile" ofType:@"csv"]
(id) $3 = 0x00000000 <nil>

是否有额外的步骤让目标识别文件?

【问题讨论】:

    标签: ios xcode4 xcode4.5 sentestingkit


    【解决方案1】:

    这是一个阅读文档类型的答案。

    事实证明,调用[NSBundle mainBundle] 不会加载包含目标文件的包。相反,我需要获取其他捆绑包标识符并使​​用该捆绑包。之后一切都按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多