Worth a read for some more context.
Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:
/// Package.xcconfig| // THIS IS A UNIVERSAL SWIFT FUNCTION BIULDER | |
| // FOR ARRAYS OF ANY TYPE | |
| // tested on Swift 5.3.1 | |
| @_functionBuilder | |
| public enum ArrayBuilder<Element> { | |
| public typealias Expression = Element | |
| public typealias Component = [Element] |
| /// A rotating 3-D cube in terminal | |
| /// Only works on macOS | |
| /// Run `swift cube.swift` in a terminal application to run it. | |
| /// For controlling the cube, see comments for `Key` in code. | |
| import Darwin | |
| enum RawModeError: Error { | |
| case notATerminal | |
| case failedToGetTerminalSetting |
| import Foundation | |
| public extension Dictionary where Key == String, Value == Any { | |
| fileprivate func _get<T>(path: [String]) -> T? { | |
| var root = self | |
| for idx in 0 ..< path.count - 1 { | |
| guard let _root = root[path[idx]] as? [String: Any] else { | |
| return nil | |
| } |
| public typealias LosslessStringCodable = LosslessStringConvertible & Codable | |
| @propertyWrapper | |
| public struct LosslessCodable<Value: LosslessStringCodable>: Codable { | |
| private let type: LosslessStringCodable.Type | |
| public var wrappedValue: Value | |
| public init(wrappedValue: Value) { | |
| self.wrappedValue = wrappedValue |
| import Foundation | |
| import SwiftUI | |
| let isUITesting = /* your UI test detection here */ | |
| @main | |
| struct EntryPoint { | |
| static func main() { | |
| if isUITesting { | |
| UITestApp.main() |
| // | |
| // Postgres+Transaction.swift | |
| // | |
| // Created by Mihael Isaev on 14.01.2020. | |
| // | |
| import Vapor | |
| import FluentKit | |
| import PostgresKit |
| import Combine | |
| import ReactiveSwift | |
| import SwiftUI | |
| class AnySubscription: Subscription { | |
| private let cancelable: Cancellable | |
| init(cancelable: Cancellable) { | |
| self.cancelable = cancelable |
Worth a read for some more context.
Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:
/// Package.xcconfig| public extension CGPoint { | |
| // The target points after decelerating to 0 velocity at a constant rate | |
| func target(initialVelocity: CGPoint, decelerationRate: CGFloat = UIScrollView.DecelerationRate.normal.rawValue) -> CGPoint { | |
| let x = self.x + self.x.target(initialVelocity: initialVelocity.x, decelerationRate: decelerationRate) | |
| let y = self.y + self.y.target(initialVelocity: initialVelocity.y, decelerationRate: decelerationRate) | |
| return CGPoint(x: x, y: y) | |
| } | |
| } |