gpt4 book ai didi

ios - 运行测试用例时 CocoaLumberJack XCTest Linker Error

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:20:31 26 4
gpt4 key购买 nike

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

这是我的 -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

错误:

Error

我已将库链接到 tests目标也如下所示,带有 libPods.a .

Linked Libraries

为什么 LumberJack 在运行测试用例时不能正确链接?是否需要向 TestTarget 添加其他内容才能正确链接?

最佳答案

我能够通过删除对 -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 配置构建的。

关于ios - 运行测试用例时 CocoaLumberJack XCTest Linker Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26021915/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com