This file contains hidden or 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
# | |
# 1. Enable build duration setting in Xcode from terminal: | |
# | |
# defaults write com.apple.dt.Xcode ShowBuildOperationDuration YE | |
# | |
# 2. add a post-installation phase to the Podfile to change the Debug Information Format setting in all targets and Pods | |
# | |
post_install do |installer| | |
puts("Update debug pod settings to speed up build time") | |
Dir.glob(File.join("Pods", "**", "Pods*{debug,Private}.xcconfig")).each do |file| |
This file contains hidden or 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
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
@MainActor | |
fileprivate struct UIViewControllerPreview<T: UIViewController>: UIViewControllerRepresentable { | |
let viewController: T | |
init(_ builder: @escaping () -> T) { viewController = builder() } | |
func makeUIViewController(context: Context) -> T { viewController } | |
func updateUIViewController(_ uiViewController: T, context: Context) { } | |
} |
This file contains hidden or 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
#!/bin/sh | |
# | |
# BUILD PLATFORM SPECIFIC FRAMEWORKS | |
# | |
# rember before use: chmod +x create_xcframework.sh | |
# iOS devices | |
xcodebuild archive \ | |
-scheme "MyLibrary iOS" \ |
This file contains hidden or 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
public extension String { | |
/// Search a json key/value and return the relative full json object | |
func searchAndDecode<T: Codable>(key: String?, value: String?) -> [T]? { | |
guard let key, let value else { return nil } | |
let pattern = "\\{[^}]*?\"\(key)\".*\"\(value)\"[^}]*\\}" | |
guard let list = self.replacingOccurrences(of: "{", with: "{\n").capture(pattern: pattern), | |
let data = "[\(list.joined(separator: ","))]".data(using: .utf8), | |
let items = try? JSONDecoder().decode([T].self, from: data) | |
else { return nil } | |
return items |
This file contains hidden or 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 | |
class WeakRef<T> where T: AnyObject { | |
private let queue = DispatchQueue(label: "ThreadSafeWeakRef.queue", attributes: .concurrent) | |
private(set) weak var _object: T? | |
weak var object: T? { | |
var result: T? |
This file contains hidden or 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
// recognized content-type | |
private let data_sign = [ | |
"7z¼¯'": "application/x-7z-compressed", | |
"AIFF": "audio/x-aiff", | |
"AVI": "video/x-msvideo", | |
"BM": "image/bmp", | |
"BZh": "application/x-bzip2", | |
"MSCF": "application/vnd.ms-cab-compressed", | |
"ITSF": "application/vnd.ms-htmlhelp", | |
"!<arch>": "application/x-debian-package", |
This file contains hidden or 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 Decodable | |
{ | |
init(_ data: Data) throws { | |
self = try JSONDecoder().decode(Self.self, from: data) | |
} | |
} | |
extension Data | |
{ | |
func toObject<T>() throws -> T? |
This file contains hidden or 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
class ConsoleLog { | |
// to log even when a device is not connected to xcode | |
// it generates a file that you can then download from the Organizer | |
// select Devices -> select device -> select app -> Dowload container | |
// after you can able show the content of file and you navigate | |
// to Document folder for get the log file. | |
static func logToFile() { | |
#if DEBUG | |
if !self.isXcode() { |
This file contains hidden or 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
// | |
// ENBaseObject.swift | |
// | |
import OHMySQL // https://github.com/oleghnidets/OHMySQL | |
import EVReflection // https://github.com/evermeer/EVReflection | |
class ENBaseObject: EVObject, OHMappingProtocol { | |
static var table: String { | |
return "\(String(describing: self).dropFirst(2))" |
NewerOlder