53 lines
1.9 KiB
Swift
53 lines
1.9 KiB
Swift
//
|
|
// BRDefine.swift
|
|
// BeeReel
|
|
//
|
|
// Created by 湖南秦九 on 2025/6/24.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
|
|
//MARK:-------------- 系统版本号 --------------
|
|
///当前系统版本号
|
|
let kBROsVersion: String = UIDevice.current.systemVersion
|
|
let kBRAPPBundleIdentifier: String = (Bundle.main.infoDictionary!["CFBundleIdentifier"] as? String) ?? "0"
|
|
|
|
///app版本号
|
|
let kBRAPPVersion: String = (Bundle.main.infoDictionary!["CFBundleShortVersionString"] as? String) ?? "0"
|
|
let kSBAPPBundleVersion: String = (Bundle.main.infoDictionary!["CFBundleVersion"] as? String) ?? "0"
|
|
|
|
let kBRAPPBundleName: String = (Bundle.main.infoDictionary!["CFBundleName"] as? String) ?? ""
|
|
let kBRAPPName: String = (Bundle.main.infoDictionary!["CFBundleDisplayName"] as? String) ?? ""
|
|
|
|
|
|
|
|
|
|
//MARK: ------- 打印信息 ----------
|
|
#if DEBUG
|
|
public func brLog(message: Any? , file: String = #file, function: String = #function, line: Int = #line) {
|
|
print("\n\(Date(timeIntervalSinceNow: 8 * 60 * 60)) \(file.components(separatedBy: "/").last ?? "") \(function) \(line): \(message ?? "")")
|
|
}
|
|
#else
|
|
public func brLog(message: Any?) { }
|
|
#endif
|
|
|
|
public func br_swizzled_instanceMethod(_ prefix: String, oldClass: Swift.AnyClass!, oldSelector: String, newClass: Swift.AnyClass) {
|
|
let newSelector = prefix + "_" + oldSelector;
|
|
let originalSelector = NSSelectorFromString(oldSelector)
|
|
let swizzledSelector = NSSelectorFromString(newSelector)
|
|
|
|
let originalMethod = class_getInstanceMethod(oldClass, originalSelector)
|
|
let swizzledMethod = class_getInstanceMethod(newClass, swizzledSelector)
|
|
|
|
let isAdd = class_addMethod(oldClass, originalSelector, method_getImplementation(swizzledMethod!), method_getTypeEncoding(swizzledMethod!))
|
|
|
|
if isAdd {
|
|
class_replaceMethod(newClass, swizzledSelector, method_getImplementation(originalMethod!), method_getTypeEncoding(originalMethod!))
|
|
}else {
|
|
method_exchangeImplementations(originalMethod!, swizzledMethod!)
|
|
}
|
|
}
|