【问题标题】:CocoaLumberJack XCTest Linker Error when running test cases运行测试用例时出现 CocoaLumberJack XCTest 链接器错误
【发布时间】:2014-09-24 16:23:59
【问题描述】:

将 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 添加其他内容才能正确链接?

【问题讨论】:

    标签: ios xctest cocoalumberjack


    【解决方案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.alibPods-MyAppTests.a 是使用新的podfile 配置构建的。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-08
        • 1970-01-01
        • 1970-01-01
        • 2013-06-21
        • 2022-11-03
        • 2018-05-23
        相关资源
        最近更新 更多