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 / 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,')
@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(
// 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 / 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
@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 / 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 / SidebarController.swift
Created June 5, 2024 05:52
A simple SwiftUI + UIHostingController sidebar implementation
//
// SidebarController.swift
//
//
// Created by Kyle on 2024/6/3.
//
import SnapKit
import SwiftUI
import UIKit
@Kyle-Ye
Kyle-Ye / iPhone Mirroring.md
Last active October 5, 2024 08:44
Launch iPhone Mirroring.app on macOS 15 Beta 1
@Kyle-Ye
Kyle-Ye / XcodeLLM.md
Last active October 30, 2024 18:00
Enable XcodeLLM for ChinaSKU Mac on macOS 15 Beta 1

Warning

The following guide need to disable SIP to work.

Please confirm the risk of disabling the SIP by yourself.

Another solution which does not require disabling SIP is currently under investigation.

Step 0

Reboot into Recovery OS + Disable SIP

@Kyle-Ye
Kyle-Ye / EnlargedTapAreaButton.swift
Created June 25, 2024 11:35
EnlargedTapAreaButton
import UIKit
open class EnlargedTapAreaButton: UIButton {
open var tapAreaInsets: UIEdgeInsets = .zero
public override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
let largerArea = bounds.inset(by: tapAreaInsets.inverted())
return largerArea.contains(point)
}
}