DotzuXiOS 調(diào)試小工具
DotzuX 是一款 iOS 調(diào)試小工具。
預(yù)覽
安裝
CocoaPods
platform :ios, '8.0' use_frameworks! target 'YourTargetName' do pod 'DotzuX', :configurations => ['Debug'] end
Carthage
github "DotzuX/DotzuX"
警告:不要在正式發(fā)布版中(比如發(fā)布到AppStore)導(dǎo)入
DotzuX.framework,因為DotzuX內(nèi)部使用了Apple的私有API,并且DotzuX使用了hook,可能會帶來不可預(yù)知的風(fēng)險。閱讀這篇集成指南,了解如何僅在Debug環(huán)境下導(dǎo)入DotzuX.framework。
使用
Swift
//Step 1.
#if DEBUG
import DotzuX
#endif
//Step 2.
#if DEBUG
DotzuX.enable()
#endif
//Step 3.
public func print<T>(file: String = #file, function: String = #function, line: Int = #line, _ message: T, color: UIColor = .white) {
#if DEBUG
swiftLog(file, function, line, message, color)
#endif
}
Objective-C
//Step 1. #ifdef DEBUG @import DotzuX; #endif //Step 2. #ifdef DEBUG [DotzuX enable]; #endif //Step 3. #ifdef DEBUG #define NSLog(fmt, ...) [DotzuX objcLog:[[NSString stringWithUTF8String:__FILE__] lastPathComponent] :NSStringFromSelector(_cmd) :__LINE__ :(fmt, ##__VA_ARGS__) :[UIColor whiteColor]] #else #define NSLog(fmt, ...) nil #endif
更多高級用法,請查看示例代碼。
注意:如果項目使用了Swift和Objective-C混編,請小心使用
Other Swift Flags和Preprocessor Macros,可以參考這里。
TODO
單元測試 (Unit Testing)
評論
圖片
表情
