This file contains hidden or 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
| struct Contact: Decodable, CustomStringConvertible { | |
| var id: String | |
| @NestedKey | |
| var firstname: String | |
| @NestedKey | |
| var lastname: String | |
| @NestedKey | |
| var address: String | |
| enum CodingKeys: String, NestableCodingKey { |
This file contains hidden or 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
| // Run any SwiftUI view as a Mac app. | |
| import Cocoa | |
| import SwiftUI | |
| NSApplication.shared.run { | |
| VStack { | |
| Text("Hello, World") | |
| .padding() | |
| .background(Capsule().fill(Color.blue)) |
This file contains hidden or 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 | |
| // Note: There are some issues with using these modifiers inside of ButtonStyles on macOS. Please see https://twitter.com/noahsark769/status/1288256379640139776?s=20 for more info. | |
| struct ConditionalContent<TrueContent: View, FalseContent: View>: View { | |
| let value: Bool | |
| let trueContent: () -> TrueContent | |
| let falseContent: () -> FalseContent | |
| @ViewBuilder var body: some View { |
This file contains hidden or 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
| clean: | |
| @# just delete specific directories instead of .builds so we don't | |
| @# have to re-fetch dependencies | |
| @rm -f .build/debug | |
| @rm -rf .build/x86_64-apple-macosx/ | |
| @rm -rf .build/x86_64-unknown-linux/ | |
| @rm -rf .build/x86_64-unknown-linux-gnu/ | |
| macos-spm-4.2: clean | |
| @echo |
This file contains hidden or 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 NSApplication (OpenAtLogin) | |
| #pragma clang diagnostic push | |
| #pragma clang diagnostic ignored "-Wdeprecated-declarations" | |
| - (BOOL)openAtLogin | |
| { | |
| LSSharedFileListItemRef loginItem = [self loginItem]; | |
| BOOL result = loginItem ? YES : NO; |
This file contains hidden or 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 XCTest | |
| // Credits: https://github.com/pointfreeco/swift-composable-architecture | |
| //swiftlint:disable empty_string force_cast force_unwrapping unused_closure_parameter function_body_length | |
| class MyCustomTestCase: XCTestCase { | |
| func assertEqual<T: Equatable>( | |
| expected: T, | |
| actual: T | |
| ) { |
OlderNewer