2

将 CocoaLumberJack 与 XCTest 一起使用时,我收到一个错误,它无法找到DDLog.h. 我试过把它<CocoaLumberjack/DDLog.h>改成没有运气。LumberJack 在 iOS 模拟器中工作时,该项目编译并运行良好,但是当我为单元测试目标运行它时,我收到此错误(请参阅屏幕截图)。

这是我的 -Prefix.pch

  #import <Availability.h>

  #ifndef __IPHONE_5_0
  #warning "This project uses features only available in iOS SDK 5.0 and later."
  #endif

  #ifdef __OBJC__
      #import <UIKit/UIKit.h>
      #import <Foundation/Foundation.h>
      #import <CoreData/CoreData.h>
      #import <CocoaLumberjack/DDLog.h>
      #import "Utilities.h"
  #endif


  #ifdef DEBUG
  static const int ddLogLevel = LOG_LEVEL_VERBOSE;
  #else
  static const int ddLogLevel = LOG_LEVEL_ERROR;
  #endif

错误:

错误

我已经将库链接到tests目标,如下所示,使用libPods.a.

链接库

为什么在运行 TestCases 时 LumberJack 不能正确链接?我还需要向 TestTarget 添加其他内容以使其正确链接吗?

4

2 回答 2

1

我能够通过删除-Prefix.pch文件的自定义并重新格式化podfile以使用目标来解决问题。我不得不移动

 #import "DDLog.h"

#ifdef DEBUG
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
static const int ddLogLevel = LOG_LEVEL_ERROR;
#endif

进入“Utility.h”类。

podfile重建以链接两个目标:

platform :ios, '7.0'

def common_pods
    pod 'CocoaLumberjack'
    pod 'HexColors'
end

target :MyApp do
    common_pods
end

target :MyAppTests do
    common_pods
end

我还不得不libPods.a从两个目标中删除它,因为它不再被构建。而是使用新配置libPods-MyApp.a构建。libPods-MyAppTests.apodfile

于 2014-09-24T18:49:43.970 回答
0

您必须Pods在项目→项目设置→信息→配置中启用配置:

https://stackoverflow.com/a/17850444/511878

于 2014-11-04T14:19:59.697 回答