Search code examples
iosobjective-cxcode8carthagecocoalumberjack

Importing CocoaLumberjack with Carthage


I am trying to import CocoaLumberjack into my project, but I always get something like

'CocoaLumberjack.h' file not found.

It is an Xcode 8 project with Objective-C and Carthage (instead of Pods). On the git page it says use version 3.2.0 for Xcode 8 and Swift 3. Is this the right version for me when I don't use Swift? Should I stick with 2.2.0? Right now I am testing with 3.2.0. 2.2.0 had issues building...

I added git "https://github.com/CocoaLumberjack/CocoaLumberjack.git" "3.2.0" or github "CocoaLumberjack/CocoaLumberjack" "3.2.0"

to the Cartfile, ran carthage update, the commands run through and they said somehting like

Checking out CocoaLumberjack at "3.2.0"

...

"CocoaLumberjack-iOS" in Lumberjack.xcworkspace Building scheme

"CocoaLumberjackSwift-iOS" in Lumberjack.xcworkspace

When it's done I open my Project-Prefix.pch and try to set some macros but I fail importing the plugin. I tried:

#import "CocoaLumberjack"
#import "<CocoaLumberjack/CocoaLumberjack.h>"
#import <CocoaLumberjack/CocoaLumberjack.h>
#import "CocoaLumberjack.h"
@import CocoaLumberjack;
@import "CocoaLumberjack"

But they all fail with some kind of

Could not build module 'CocoaLumberjack'

or

'' file not found

errors.

How do I import this correctly? Is there any clue in the project hierarchy where I can see whether adding it with Carthage worked or not?


Solution

  • For resolving the dependencies you do carthage update, but after this do you run carthage build? Then after the building process, add the framework CocoaLumberjack.framework (you can find it in the folder Carthage/Build/iOS) to your main project


    moreover please be sure to have this configuration: enter image description here

    finally you should be able to import the library in this way:

    #import <CocoaLumberjack/CocoaLumberjack.h>
    

    usage example:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        [DDLog addLogger:[DDASLLogger sharedInstance]];
        return YES;
    }