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
# Add to your zsh profile | |
function devicepid() { | |
if [ -z "$1" ]; then | |
echo "Usage: devicepid <device-name> <search>" | |
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard" | |
return 1 | |
fi | |
if [ -z "$2" ]; then |
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
import SwiftUI | |
#if !os(watchOS) | |
#if canImport(UIKit) | |
public typealias PlatformViewRepresentableType = UIViewRepresentable | |
#else | |
public typealias PlatformViewRepresentableType = NSViewRepresentable | |
#endif // canImport(UIKit) |
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
if [ "$EFFECTIVE_PLATFORM_NAME" = "-maccatalyst" ]; then | |
echo "Adding com.apple.developer.homekit entitlement" | |
/usr/libexec/PlistBuddy -c "Add :com.apple.developer.homekit bool true" "$TARGET_TEMP_DIR/$FULL_PRODUCT_NAME.xcent" | |
fi |
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
import SwiftUI | |
#if os(iOS) || os(tvOS) | |
public typealias PlatformView = UIView | |
public typealias PlatformViewRepresentable = UIViewRepresentable | |
#elseif os(macOS) | |
public typealias PlatformView = NSView | |
public typealias PlatformViewRepresentable = NSViewRepresentable | |
#endif |
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
/** | |
Implementation of the "atoi" function in Swift. | |
This implementation is an exercise and should not be used in production, | |
Swift has built-in types and functions that can do this sort of conversion. | |
*/ | |
/// Parses the input string as a 32-bit integer. | |
/// Returns `nil` if the input contains non-ASCII characters, or is not a valid number. | |
func myAtoi(_ input: String) -> Int32? { | |
/// The base ASCII code, where the numbers begin. |
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
import SwiftUI | |
/// On macOS, modifying an Animation with .currentSpeed(), or using the .current static property | |
/// allows for easy animation debugging by holding down the Shift key when triggering the animation. | |
/// When the animation is triggered while the Shift key is pressed, it will be played in slow motion. | |
/// Using this extension has no effect when targeting other OSes or when building for release. | |
extension Animation { | |
static var currentSpeed: Double { | |
#if DEBUG |
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
#if DEBUG | |
/* | |
This fixes SwiftUI previews not rendering translucent materials correctly by | |
swizzling a couple of properties on NSWindow. | |
Just drop into your project and add to the target being previewed (or something it links against). | |
Notice the #if DEBUG, so this code won't end up in release builds. It also checks for the | |
XCODE_RUNNING_FOR_PREVIEWS environment variable so that it won't affect regular debug builds of the app. |
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
/* | |
Example: | |
let v1 = SemanticVersion(string: "1.0.0") | |
let v2 = SemanticVersion(string: "2.0.0") | |
print(v1 > v2) // false | |
print(v2 > v1) // true |
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
# Add this to a "Run Script" build phase in your app's main target, as the last step. | |
# It will use the pluginkit command-line tool to force the plugin system on macOS to add your extensions to its database, making them available. | |
# I made this specifically for widgets, but it should work for pretty much any extension type (appex bundle). | |
find $CODESIGNING_FOLDER_PATH -name '*.appex' -exec pluginkit -a {} \; |
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 ReferenceEncodable: Identifiable { | |
static var referenceStorageKey: CodingUserInfoKey { get } | |
} | |
extension ReferenceEncodable { | |
static var referenceStorageKey: CodingUserInfoKey { | |
CodingUserInfoKey(rawValue: String(describing: Self.self) + "ReferenceStorage")! | |
} | |
} |
NewerOlder