Skip to content

Instantly share code, notes, and snippets.

View AchrafKassioui's full-sized avatar

Achraf Kassioui AchrafKassioui

View GitHub Profile
@arthurschiller
arthurschiller / realitview_scene+subscriptions.swift
Created August 4, 2024 11:23
RealityView Example for accessing scene and subscribing to events
import SwiftUI
import RealityKit
import Combine
struct ContentView: View {
@Environment(\.realityKitScene) var scene: RealityKit.Scene?
@State private var didAddEntitySubscription: Cancellable?
@rsms
rsms / macos-distribution.md
Last active October 31, 2025 06:37
macOS distribution — code signing, notarization, quarantine, distribution vehicles
@emin-grbo
emin-grbo / decodeOrReport.swift
Created February 13, 2024 10:39
DecodeOrReport
// Used to detect specific issue with JSON decoding
func decodeOrReport(data: Data) {
do {
let _ = try JSONDecoder().decode(WidgetResponse.self, from: data)
print("\n\n👍ALL GOOD\n\n")
} catch DecodingError.keyNotFound( let key, let context) {
print("\n\n⛔️FAILED TO DECODE\n\n")
print("could not find key \(key) in JSON: \(context.debugDescription)")
} catch DecodingError.valueNotFound( let type, let context) {
print("\n\n⛔️FAILED TO DECODE\n\n")
@arthurschiller
arthurschiller / RealityRendererTest.swift
Last active November 20, 2025 17:29
RealityRenderer Test (visionOS)
//
// RealityRendererView.swift
// RealityRendererTest
//
// Created by Arthur Schiller on 11.01.24.
//
import SwiftUI
import Metal
import MetalKit
@overlair
overlair / Coordinate-Conversion.swift
Last active October 31, 2023 00:49
SpriteKit-Coordinate-Conversion
import SpriteKit
import SwiftUI
import Combine
enum ControlUpdate {
case tap(UITapGestureRecognizer) // print SpriteKit coordinate
case doubleTap // reset camera
case pan(UIPanGestureRecognizer) // move camera
@overlair
overlair / SwiftUI+Combine+SpriteKit-Example.swift
Last active October 29, 2023 19:33
SwiftUI+Combine+SpriteKit
import SpriteKit
import SwiftUI
import Combine
/*
SpriteKit -> SwiftUI data message
*/
enum StateUpdate {
case color(UIColor)
@overlair
overlair / ExampleUIKitGestures.swift
Created October 28, 2023 03:26
UIKit Gestures in SwiftUI
import SwiftUI
struct ExampleUIKitGestureViewA: View {
var body: some View {
Color.blue
.overlay { ExampleUIKitGestureViewRepresentableA() }
/*
can also place it behind if hits are disabled on attaching view,
or you have other views you want to receive gestures that it would block
@runys
runys / SquareGame-After.swift
Last active July 14, 2023 01:28
Example code of a simple integration between SwiftUI and SpriteKit using the delegate pattern.
import SwiftUI
import SpriteKit
protocol SquareGameLogicDelegate {
var totalScore: Int { get }
mutating func addPoint() -> Void
}
// 1. Conform the ContentView to the SquareLogicDelegate protocol
@Umity
Umity / CIFilter+Extension.swift
Created August 30, 2018 21:26 — forked from ha1f/CIFilter+Extension.swift
CIFilter+Extension.swift
//
// Created by はるふ on 2017/12/11.
// Copyright © 2017年 ha1f. All rights reserved.
//
import Foundation
import CoreImage
import AVFoundation
extension CIFilter {
@matthewreagan
matthewreagan / Perlin
Last active March 30, 2024 16:18
Perlin noise generation in Swift
// Perlin.swift
// Created by Matthew Reagan on 8/7/18.
//
// Quick implementation of the the classic Perlin noise
// generation function, useful for creating organic textures
// or terrain. Perlin noise can also be easily generated with
// Apple's GameplayKit framework, this code is mostly for
// experimentation purposes. (Disclaimer: This code is not
// optimized, nor particularly elegant, but it can be used as
// a jumping off point for writing custom noise functions.)