This article describes how to use Crashlytics logging in objective-c. However, after going throught the installation steps for propertly referencing Crashlytics and Fabric into my project, I don't seem to have access to that method.
Looking at the Crashlytics.h file, I can see it defined using compiler flags:
#ifdef DEBUG
#define CLS_LOG(__FORMAT__, ...) CLSNSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define CLS_LOG(__FORMAT__, ...) CLSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif
This block just appears to wrap the CLSNLog
and the CLSLog
functions depending on the compiler flag.
So, thinking I'd just go straight to the source, I tried to reference CLSLog directly from a swift file. Still no luck:
My-Bridging-Header.h:
#import <Crashlytics/Crashlytics.h>
Log.swift:
import Foundation
import Fabric
import Crashlytics
func Log(message: String) {
NSLog("%@", message)
CLS_LOG("%@", message)
CLSLog("%@", message)
}
The last two lines in the Log function throw the error, Use of unresolved identifier
. Crashlytics crash reporting works just fine, except for the logging feature. According to this article, logging support for Swift has been implemented.
As far as versions go, I'm running the latest version of Fabric/Crashlytics (December release, at the time of this post).
(Interesting note, I can see/use CLSLogv()
...)
Does anyone know the correct way to incorporate CLS_LOG
for use in a Swift project?
CLS_LOG()
usually contains.__PRETTY_FUNCTION__
and__LINE__
become useless because they will simply print out information about your wrapper rather than the calling code. See my answer for a functioning adapter/bridge in swift where this information is printed correctly. – Oba