When using CocoaLumberJack with XCTest, I get an error that it cannot find the DDLog.h
. I've tried changing it to <CocoaLumberjack/DDLog.h>
with no luck. 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).
Here is my -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
.
Why won't LumberJack link properly when running the TestCases? Is there something else I need to add to the TestTarget for it to link properly?
I was able to resolve the issue by removing the customizations to the -Prefix.pch
file and reformat the podfile
to use targets. 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.
The podfile
was rebuilt to link both targets:
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. Instead libPods-MyApp.a
and libPods-MyAppTests.a
are built with the new podfile
configuration.