Skip to content

Instantly share code, notes, and snippets.

/// An async-safe lazy variable wrapper, possibly suitable for using with global
/// variables in Swift 6.
///
/// From https://developer.apple.com/documentation/realitykit/rendering-a-windowed-game-in-stereo
actor LazyAsync<T: Sendable> {
private var value: T?
private let closure: () async -> T
//
// Task+SleepForSeconds.swift
//
// Created by Drew Olbrich on 7/12/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
//
// InputNotWorkingIndicator.swift
//
// Created by Drew Olbrich on 6/26/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
//
// VolumeBaseplateVisibility_visionOS2.swift
//
// Created by Drew Olbrich on 6/25/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / VolumeWorldAlignment_visionOS2.swift
Last active July 20, 2024 00:52
Wrapper around visionOS 2 volumeWorldAlignment that is a no-op in visionOS 1
//
// VolumeWorldAlignment_visionOS2.swift
//
// Created by Drew Olbrich on 6/15/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / DefaultWindowPlacement_visionOS2.swift
Last active June 26, 2024 00:34
Wrapper around SwiftUI defaultWindowPlacement that is a no-op on visionOS 1
//
// DefaultWindowPlacement_visionOS2.swift
//
// Created by Drew Olbrich on 6/11/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / CoordinateSpaceAxesEntity.swift
Last active May 14, 2024 23:42
A RelaityKit entity that draws coordinate space axes
//
// CoordinateSpaceAxesEntity.swift
//
// Created by Drew Olbrich on 7/8/23.
// Copyright © 2023 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / ScrollViewProxy+ScrollToAnimated.swift
Created May 11, 2024 22:22
A wrapper for ScrollViewProxy/scrollTo that works around a bug where withAnimation doesn't always work
//
// ScrollViewProxy+ScrollToAnimated.swift
//
// Created by Drew Olbrich on 5/11/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
//
// View+AttachmentPivot.swift
//
// Created by Drew Olbrich on 4/11/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / View+WindowGeometryPreferences.swift
Last active July 18, 2024 04:11
A visionOS SwiftUI view modifier that can be used to hide a window's resize handles or to constrain a window's aspect ratio
//
// View+WindowGeometryPreferences.swift
//
// Created by Drew Olbrich on 1/30/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal