Skip to content

Instantly share code, notes, and snippets.

View artemnovichkov's full-sized avatar
👨‍💻
Write code. Blow minds.

Artem Novichkov artemnovichkov

👨‍💻
Write code. Blow minds.
View GitHub Profile
@artemnovichkov
artemnovichkov / file_sharing.swift
Last active September 13, 2022 14:20
Explore Documents folder in Files.app. Inspired by Ole's tweet https://twitter.com/olebegemann/status/987346188591681536
#!/usr/bin/env xcrun --sdk macosx swift
import Foundation
enum Configuration: String {
case debug = "Debug"
case release = "Release"
}
// Get Info.plist path
struct User {
let username: String
}
final class user Service {
static let shared = Service()
var user: User?
}
import Foundation
extension URL {
/// Returns an url for App Store app.
///
/// Example: [itms-apps://itunes.apple.com/app/id1434568484?action=write-review]()
///
/// - Parameters:
/// - id: The id of the app.
// Create an interator class
class ElementIterator<T>: IteratorProtocol {
typealias Element = T
let element: T
init(element: T) {
self.element = element
}
@artemnovichkov
artemnovichkov / travis.yml
Last active August 27, 2019 07:13
Travis CI configuration from Texstyle https://github.com/rosberry/texstyle
language: swift
osx_image: xcode10.2
env:
matrix:
- DESTINATION="platform=iOS Simulator,OS=12.2,name=iPhone X"
- DESTINATION="platform=tvOS Simulator,OS=12.2,name=Apple TV 4K"
before_script: cd Texstyle
@artemnovichkov
artemnovichkov / test.yml
Created August 27, 2019 12:14
Github Actions configuration for Texstyle https://github.com/rosberry/texstyle
on: pull_request
name: Test
jobs:
test:
name: Test
runs-on: macOS-latest
strategy:
matrix:
destination: ['platform=iOS Simulator,OS=12.2,name=iPhone X', 'platform=tvOS Simulator,OS=12.2,name=Apple TV 4K']
steps:
@artemnovichkov
artemnovichkov / Logging.swift
Created November 21, 2019 04:28
Swift Property Wrapper for logging
@propertyWrapper
struct Logging<T> {
var value: T
init(wrappedValue value: T) {
self.value = value
}
var wrappedValue: T {
@artemnovichkov
artemnovichkov / ViewController.swift
Last active December 16, 2019 03:18
An example of using Xcode Preview for projects without SwiftUI.
final class ViewController: UIViewController {
}
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct ViewControllerRepresentable: UIViewRepresentable {
func makeUIView(context: Context) -> UIView {
@artemnovichkov
artemnovichkov / UIColor+DarkMode.swift
Last active July 3, 2023 14:51
UIColor convenience initializer for Dark Mode
import UIKit
public extension UIColor {
/// Creates a color object that generates its color data dynamically using the specified colors. For early SDKs creates light color.
/// - Parameters:
/// - light: The color for light mode.
/// - dark: The color for dark mode.
convenience init(light: UIColor, dark: UIColor) {
if #available(iOS 13.0, tvOS 13.0, *) {
@artemnovichkov
artemnovichkov / UIImageAsset+TraitCollection.swift
Last active December 16, 2019 03:08
An UIImageAsset extension with Dark Mode
import UIKit
public extension UIImageAsset {
/// Creates an image asset with registration of tht eimages with the light and dark trait collections.
/// - Parameters:
/// - lightModeImage: The image you want to register with the image asset with light user interface style.
/// - darkModeImage: The image you want to register with the image asset with dark user interface style.
convenience init(lightModeImage: UIImage?, darkModeImage: UIImage?) {
self.init()