简体   繁体   English

使用 Carthage 导入 CocoaLumberjack

[英]Importing CocoaLumberjack with Carthage

I am trying to import CocoaLumberjack into my project, but I always get something like我正在尝试将 CocoaLumberjack 导入我的项目,但我总是得到类似

'CocoaLumberjack.h' file not found.找不到“CocoaLumberjack.h”文件。

It is an Xcode 8 project with Objective-C and Carthage (instead of Pods).它是一个带有 Objective-C 和 Carthage(而不是 Pods)的 Xcode 8 项目。 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?git 页面上,它说对 Xcode 8 和 Swift 3 使用版本 3.2.0。当我不使用 Swift 时,这是适合我的版本吗? Should I stick with 2.2.0?我应该坚持使用 2.2.0 吗? Right now I am testing with 3.2.0.现在我正在测试 3.2.0。 2.2.0 had issues building... 2.2.0 有问题构建...

I added git "https://github.com/CocoaLumberjack/CocoaLumberjack.git" "3.2.0" or github "CocoaLumberjack/CocoaLumberjack" "3.2.0"我添加了git "https://github.com/CocoaLumberjack/CocoaLumberjack.git" "3.2.0"github "CocoaLumberjack/CocoaLumberjack" "3.2.0"

to the Cartfile, ran carthage update , the commands run through and they said somehting like到 Cartfile,运行carthage update ,运行命令,他们说类似

Checking out CocoaLumberjack at "3.2.0"在“3.2.0”查看 CocoaLumberjack

... ...

"CocoaLumberjack-iOS" in Lumberjack.xcworkspace Building scheme Lumberjack.xcworkspace 建筑方案中的“CocoaLumberjack-iOS”

"CocoaLumberjackSwift-iOS" in Lumberjack.xcworkspace Lumberjack.xcworkspace 中的“CocoaLumberjackSwift-iOS”

When it's done I open my Project-Prefix.pch and try to set some macros but I fail importing the plugin.完成后,我打开 Project-Prefix.pch 并尝试设置一些宏,但无法导入插件。 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'无法构建模块“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?项目层次结构中是否有任何线索可以查看将其添加到 Carthage 是否有效?

For resolving the dependencies you do carthage update , but after this do you run carthage build ?为了解决依赖关系,您执行carthage update ,但是在此之后您运行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然后在构建过程之后,将框架CocoaLumberjack.framework (您可以在Carthage/Build/iOS文件夹中找到它)添加到您的主项目中


moreover please be sure to have this configuration:此外,请确保具有以下配置: 在此处输入图片说明

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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM