Skip to content

Instantly share code, notes, and snippets.

View vlas-voloshin's full-sized avatar

Vlas Voloshin vlas-voloshin

View GitHub Profile
@vlas-voloshin
vlas-voloshin / LazyState.swift
Created September 13, 2025 05:46
Replacement for StateObject property wrapper for Observable objects
import SwiftUI
/// A property wrapper type that instantiates an observable object.
///
/// This is a wrapper for `State` that works with `Observable` values and provides "lazy" initialization semantics similar to `StateObject`.
@MainActor @propertyWrapper
struct LazyState<Value: Observable & AnyObject>: @preconcurrency DynamicProperty {
var wrappedValue: Value {
guard let value = storage.value else {
@vlas-voloshin
vlas-voloshin / delete-duplicate-sims.rb
Last active March 20, 2025 05:23
Script for deleting duplicate iOS simulators and fixing simulators list in Xcode
#!/usr/bin/env ruby
# What is this for?
# This script fixes an issue appeared for some Xcode users where it would show long identifiers
# in the list of simulators instead of usual short names. This is caused by duplicate simulators
# being sometimes created after switching between Xcode versions, with the same
# device type + runtime pair occurring more than once in your list of available simulators.
# Instead of showing the same simulator name twice, Xcode defaults to simulator identifiers.
#
# What it does?