[英]CocoaLumberJack XCTest Linker Error when running test cases
When using CocoaLumberJack with XCTest, I get an error that it cannot find the DDLog.h
.将 CocoaLumberJack 与 XCTest 一起使用时,我收到一个错误,提示它找不到
DDLog.h
。 I've tried changing it to <CocoaLumberjack/DDLog.h>
with no luck.我尝试将其更改为
<CocoaLumberjack/DDLog.h>
,但没有成功。 The project compiles and runs fine with LumberJack working in the iOS Simulator, but when I run it for the unit testing target, I get this error (See Screenshot).该项目通过 LumberJack 在 iOS 模拟器中编译并运行良好,但是当我为单元测试目标运行它时,出现此错误(请参阅屏幕截图)。
Here is my -Prefix.pch这是我的 -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:错误:
I've linked the libraries to to the tests
target also as shown below with the libPods.a
.我已将库链接到
tests
目标,如下所示,使用libPods.a
。
Why won't LumberJack link properly when running the TestCases?为什么在运行测试用例时 LumberJack 无法正确链接? Is there something else I need to add to the TestTarget for it to link properly?
我还需要向 TestTarget 添加其他内容才能正确链接吗?
I was able to resolve the issue by removing the customizations to the -Prefix.pch
file and reformat the podfile
to use targets.我能够通过删除对
-Prefix.pch
文件的自定义并重新格式化podfile
以使用目标来解决该问题。 I had to move the我不得不移动
#import "DDLog.h"
and和
#ifdef DEBUG
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
static const int ddLogLevel = LOG_LEVEL_ERROR;
#endif
into a `Utility.h' class.进入“Utility.h”类。
The podfile
was rebuilt to link both targets:重新构建
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
I also had to remove the libPods.a
from both targets since it would no longer be built.我还必须从两个目标中删除
libPods.a
,因为它将不再构建。 Instead libPods-MyApp.a
and libPods-MyAppTests.a
are built with the new podfile
configuration.相反,
libPods-MyApp.a
和libPods-MyAppTests.a
是使用新的podfile
配置构建的。
You have to enable Pods
configuration in your project → project settings → info → configurations:您必须在项目 → 项目设置 → 信息 → 配置中启用
Pods
配置:
https://stackoverflow.com/a/17850444/511878 https://stackoverflow.com/a/17850444/511878
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.