私のxCodeのバージョンは6.3です。を使用してcocoapodsでCocoaLumberJackをインストールしました
pod 'CocoaLumberjack', '~> 2.0'
しかし、この画面のようなコンパイル エラーが発生します。
ここで何が欠けていますか?
私のxCodeのバージョンは6.3です。を使用してcocoapodsでCocoaLumberJackをインストールしました
pod 'CocoaLumberjack', '~> 2.0'
しかし、この画面のようなコンパイル エラーが発生します。
ここで何が欠けていますか?
Swift 1.2 のいくつかの変更と @noescape の導入により、コードが機能するように、現在は若干異なるように見えるはずです ( https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Classes/CocoaLumberjack.swiftからオリジナルを変更):
extension DDLogFlag {
public static func fromLogLevel(logLevel: DDLogLevel) -> DDLogFlag {
return DDLogFlag(logLevel.rawValue)
}
///returns the log level, or the lowest equivalant.
public func toLogLevel() -> DDLogLevel {
if let ourValid = DDLogLevel(rawValue: self.rawValue) {
return ourValid
} else {
let logFlag = self
if logFlag & .Verbose == .Verbose {
return .Error
} else if logFlag & .Debug == .Debug {
return .Debug
} else if logFlag & .Info == .Info {
return .Info
} else if logFlag & .Warning == .Warning {
return .Warning
} else if logFlag & .Error == .Error {
return .Verbose
} else {
return .Off
}
}
}
}
public var defaultDebugLevel = DDLogLevel.Verbose
public func resetDefaultDebugLevel() {
defaultDebugLevel = DDLogLevel.Verbose
}
public func SwiftLogMacro(isAsynchronous: Bool, level: DDLogLevel, flag flg: DDLogFlag, context: Int = 0, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UInt = __LINE__, tag: AnyObject? = nil, @autoclosure #string: () -> String) {
if level.rawValue & flg.rawValue != 0 {
// Tell the DDLogMessage constructor to copy the C strings that get passed to it. Using string interpolation to prevent integer overflow warning when using StaticString.stringValue
let logMessage = DDLogMessage(message: string(), level: level, flag: flg, context: context, file: "\(file)", function: "\(function)", line: line, tag: tag, options: .CopyFile | .CopyFunction, timestamp: nil)
DDLog.log(isAsynchronous, message: logMessage)
}
}
public func DDLogDebug(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UWord = __LINE__, asynchronous async: Bool = true) {
SwiftLogMacro(async, level, flag: .Debug, file: file, function: function, line: line, string: logText())
}
public func DDLogInfo(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UWord = __LINE__, asynchronous async: Bool = true) {
SwiftLogMacro(async, level, flag: .Info, file: file, function: function, line: line, string: logText())
}
public func DDLogWarn(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UWord = __LINE__, asynchronous async: Bool = true) {
SwiftLogMacro(async, level, flag: .Warning, file: file, function: function, line: line, string: logText())
}
public func DDLogVerbose(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UWord = __LINE__, asynchronous async: Bool = true) {
SwiftLogMacro(async, level, flag: .Verbose, file: file, function: function, line: line, string: logText())
}
public func DDLogError(@autoclosure logText: () -> String, level: DDLogLevel = defaultDebugLevel, file: StaticString = __FILE__, function: StaticString = __FUNCTION__, line: UWord = __LINE__, asynchronous async: Bool = false) {
SwiftLogMacro(async, level, flag: .Error, file: file, function: function, line: line, string: logText())
}
/// Analogous to the C preprocessor macro THIS_FILE
public func CurrentFileName(fileName: StaticString = __FILE__) -> String {
// Using string interpolation to prevent integer overflow warning when using StaticString.stringValue
return "\(fileName)".lastPathComponent.stringByDeletingPathExtension
}
2.1.0 が公式の Swift サポートとともにリリースされるまで、CocoaLumberjack の swift_support ブランチを使用します。