This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Lokalise downloading and copying | |
// Lokalise Constants | |
let LokalisePOSTUrl = "https://api.lokalise.co/api2/projects/\(lokaliseProjectId)/files/download" | |
let LokalizableZipName = "Mobile-Localizable" | |
struct LokaliseRequestBody: Codable { | |
let format = "ios_sdk" | |
let original_filenames = true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK:- Scripting | |
func shell(launchPath: String, arguments: [String]) -> String | |
{ | |
let task = Process() | |
task.launchPath = launchPath | |
task.arguments = arguments | |
let pipe = Pipe() | |
task.standardOutput = pipe | |
task.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// ... | |
/// The tr() method to update with the Lokalise call: | |
extension {{enumName}} { | |
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { | |
let format = Lokalise.shared.localizedString(forKey: key, value: nil, table: table) | |
return String(format: format, locale: Locale.current, arguments: args) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: OSLog extension | |
extension SwiftyBeaver { | |
private static var osLogDestination: OSLogDestination = { | |
#if DEBUG | |
let level: SwiftyBeaver.Level = .verbose | |
#else | |
let level: SwiftyBeaver.Level = .error | |
#endif | |
let osLogDestination = OSLogDestination(level: level) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SwiftyBeaver.setupConsole() | |
SwiftyBeaver.setOSLog(enabled: true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftyBeaver | |
import os | |
final class OSLogDestination: BaseDestination { | |
fileprivate var level: SwiftyBeaver.Level | |
init(level: SwiftyBeaver.Level) { | |
self.level = level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createOSLog(context: Any?) -> OSLog { | |
var currentContext = "Default" | |
if let loggerContext = context as? String { | |
currentContext = loggerContext | |
} | |
let subsystem = Bundle.main.bundleIdentifier ?? "com.logger.default" | |
let customLog = OSLog(subsystem: subsystem, category: currentContext) | |
return customLog | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension SwiftyBeaver { | |
// ... | |
static func addOSLogDestination() { | |
#if DEBUG | |
let level: SwiftyBeaver.Level = .verbose | |
#else | |
let level: SwiftyBeaver.Level = .error | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SwiftyBeaver.setupConsole() | |
logger.debug("Hello, I'm a |debug| log") | |
logger.verbose("Hello, I'm a |verbose| log") | |
logger.warning("Hello, I'm a |warning| log") | |
logger.info("Hello, I'm a |info| log") | |
logger.error("Hello, I'm a |error| log") |