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 / UICollectionViewCell+RCTRootViewDemo.swift
Last active November 13, 2024 14:19
Workaround for UICollectionViewCell+RCTRootView
import Dispatch
import Foundation
import UIKit
extension DispatchQueue {
/// Run the action immediately if it's on the main thread, otherwise dispatch it to the main thread asynchronously.
public static func onMainThread(_ action: @escaping () -> Void) {
if Thread.isMainThread {
action()
} else {
@Kyle-Ye
Kyle-Ye / build.sh
Last active October 21, 2024 08:58
Swift 5.10 Build script
// Set up swift repo
mkdir -p ~/tmp/build/swift-project
cd ~/tmp/build/swift-project
git clone [email protected]:swiftlang/swift.git
// Update the swift-project
cd swift
utils/update-checkout --clone-with-ssh
// Check out to the 5.10 release
@Kyle-Ye
Kyle-Ye / build_xcframework.sh
Created October 13, 2024 08:13
Generate xcframework for Swift package
#!/bin/bash
# Script modified from https://docs.emergetools.com/docs/analyzing-a-spm-framework-ios
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd -P)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
PROJECT_BUILD_DIR="${PROJECT_BUILD_DIR:-"${PROJECT_ROOT}/build"}"
@Kyle-Ye
Kyle-Ye / InputHostingViewController.swift
Created August 1, 2024 13:19
SwiftUI + UIInputViewController
// Based on https://gist.github.com/liamnichols/a2e656ae93a597952b4427bcfa371185
// Add allowsSelfSizing support to support inputViewController custom height
// If you need fully dynamic height, please try https://gist.github.com/hannesoid/74ec9022021835598acf17564ce76a5a
/// `UIInputViewController` subclass that wraps a `UIHostingController` allowing you to embed SwiftUI inside `inputAccessoryViewController` and friends.
fileprivate class InputHostingViewController<Content: View>: UIInputViewController {
let hostingViewController: UIHostingController<Content>
init(rootView: Content) {
self.hostingViewController = UIHostingController(rootView: rootView)
super.init(nibName: nil, bundle: nil)
@Kyle-Ye
Kyle-Ye / UnevenRoundedRectangle.swift
Last active July 24, 2024 17:52
An UnevenRoundedRectangle implementation available on iOS 14+
//
// UnevenRoundedRectangle.swift
//
//
// Created by Kyle on 2024/7/24.
//
import SwiftUI
@frozen
@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)
}
}
@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 / iPhone Mirroring.md
Last active October 5, 2024 08:44
Launch iPhone Mirroring.app on macOS 15 Beta 1
@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 / 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 {