This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"workbench.colorCustomizations": { | |
"activityBar.activeBackground": "#dc0000", | |
"activityBar.activeBorder": "#03A9F4", | |
"activityBar.background": "#860009", | |
"activityBar.foreground": "#e7e7e7", | |
"activityBar.inactiveForeground": "#e7e7e799", | |
"activityBarBadge.background": "#03A9F4", | |
"activityBarBadge.foreground": "#e7e7e7", | |
"statusBar.background": "#03A9F4", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Publisher where Failure == Never { | |
func weakAssign<T: AnyObject>( | |
to keyPath: ReferenceWritableKeyPath<T, Output>, on object: T | |
) -> AnyCancellable { | |
sink { [weak object] value in | |
object?[keyPath: keyPath] = value | |
} | |
} | |
func weakSink<T: AnyObject>( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Publisher { | |
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) | |
func asyncFirst() async throws -> Output? { | |
return try await self | |
.first() | |
.values | |
.first { _ in true } | |
} | |
// https://medium.com/geekculture/from-combine-to-async-await-c08bf1d15b77 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://www.hackingwithswift.com/plus/high-performance-apps/using-memoization-to-speed-up-slow-functions | |
// Source: https://medium.com/@mvxlr/swift-memoize-walk-through-c5224a558194 | |
typealias MemFn<Input, Output> = (Input) -> Output | |
// work with any sort of input and output as long as the input is hashable | |
// accept a function that takes Input and returns Output, and return a function with the same signature | |
func memoize<Input: Hashable, Output>( | |
_ work: @escaping MemFn<Input, Output> | |
) -> MemFn<Input, Output> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defaults write com.apple.dt.Xcode IDEModelAccessHasUserConsentForOnDeviceInteractions -bool FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://milen.me/writings/auto-linking-on-ios-and-macos/ | |
// This works | |
OTHER_SWIFT_FLAGS = $(inherited) -Xfrontend -disable-autolink-framework -Xfrontend TestFramework | |
// This doesn't work, even though it is referenced here: | |
// https://github.com/apple/swift/blob/main/include/swift/Option/FrontendOptions.td#L531C47-L531C74 | |
//OTHER_SWIFT_FLAGS = $(inherited) -Xfrontend -disable-autolink-frameworks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc public protocol TestProto1 {} | |
public protocol TestProto2: Hashable {} | |
public enum Destination: Hashable, Equatable { | |
// OKAY - Concrete | |
case test(obj: NSObject) | |
// Error: any type (not concrete/boxed) | |
// Type 'AppFeatureDestination' does not conform to protocol 'Equatable' | |
case test1(obj: NSObject & TestProto1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol HashableBox: Hashable { | |
func `as`<T : Hashable>(_: T.Type) -> T? | |
func isEqual(_ other: any HashableBox) -> Bool | |
} | |
struct ConcreteHashableBox<Base: Hashable>: HashableBox { | |
let base: Base | |
func `as`<T>(_: T.Type) -> T? where T : Hashable { | |
return base as? T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Modified from: https://stackoverflow.com/a/45882589 | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { | |
var freeMem = Int.max | |
let reserved = 605696 | |
let chunks = 12000 | |
repeat { | |
freeMem = os_proc_available_memory() | |
let toAlloc = freeMem | |
let mallocSize = toAlloc / chunks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get all dynamically linked framework dependencies | |
# sort -u is necessary for FAT targets such as iphonesimulator builds | |
otool -L "/path/to/Example.framework/Example" | \ | |
grep '@rpath' | grep '.framework' | awk '{ print $1 }' | cut -d '/' -f2 | \ | |
xargs -I{} basename "{}" ".framework" | \ | |
sort -u | \ | |
grep -v "Example" | \ | |
while IFS=$'\n' read -r dependency; do | |
echo "$dependency" | |
done |