Skip to content

Instantly share code, notes, and snippets.

View Kyle-Ye's full-sized avatar
💭

Kyle Kyle-Ye

💭
View GitHub Profile
@Kyle-Ye
Kyle-Ye / showSizes.swift
Last active May 11, 2024 03:56 — forked from swiftui-lab/showSizes.swift
A debugging modifier for SwiftUI views (showSizes)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Implementation of the showSizes() debugging modifier
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct MeasureExample: View {
var body: some View {
VStack {
@Kyle-Ye
Kyle-Ye / TappablePadding.swift
Last active April 23, 2024 15:57
SwiftUI TappablePadding
struct TappablePadding: ViewModifier {
let edges: Edge.Set
let insets: EdgeInsets?
let perform: () -> Void
init(edges: Edge.Set = .all, insets: EdgeInsets?, perform: @escaping () -> Void) {
self.edges = edges
self.insets = insets
self.perform = perform
@Kyle-Ye
Kyle-Ye / APIKeyManager.swift
Last active November 25, 2023 18:21
RSA key generation and export in Swift
//
// APIKeyManager.swift
// Demo
//
// Created by Kyle on 2023/11/25.
//
import Foundation
import Security
// The behavior before iOS 17/Xcode 15:
// Dynamic Island Device: Alert if app is in background
// non-Dynamic Island Device: Alert if app is in background
//
// The behavior after iOS 17/Xcode 15:
// Dynamic Island Device: Alert if or after app is in background
// non-Dynamic Island Device: Alert immediately
//
// "Alert" means a pop-up live activity card with white backgroun
// To workaround the buggy UI behavior for non-Dynamic Island Device on iOS 17
@Kyle-Ye
Kyle-Ye / Package.swift
Created May 7, 2023 07:48
Add system framework search path on Package.swift
// swift-tools-version: 5.8
// The swift-tools-version declares the minimum version of Swift required to build this package.
import Foundation
import PackageDescription
let isXcodeEnv = ProcessInfo.processInfo.environment["__CFBundleIdentifier"] == "com.apple.dt.Xcode"
// Xcode use clang as linker which supports "-iframework" while SwiftPM use swiftc as linker which supports "-Fsystem"
let systemFrameworkSearchFlag = isXcodeEnv ? "-iframework" : "-Fsystem"
let package = Package(
@Kyle-Ye
Kyle-Ye / script.sh
Last active November 26, 2022 01:02
XNU build script
download() {
gh repo clone apple-oss-distributions/distribution-macOS
cd distribution-macOS
# checkout to macos-123 since Xcode 13.4 is bundled with macOS 12.3 SDK
git checkout tags/macos-123
export TOOLCHAIN_PATH=$(cd `xcrun -sdk macosx -show-sdk-platform-path`/../../Toolchains/XcodeDefault.xctoolchain && pwd)
export SDKPATH=$(xcrun -sdk macosx -show-sdk-path)
export XCODEPATH=$(xcrun -sdk macosx -show-sdk-path | sed 's,\(.*/Xcode[^/]*\.app\)/.*,\1,')