From 618f7de11086a78a46e12ef55546840fa596635c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jun 2022 20:17:27 -0300 Subject: [PATCH 1/8] Bump jmespath from 1.4.0 to 1.6.1 (#1015) --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4c17df332..6966e1767 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -222,7 +222,7 @@ GEM httpclient (2.8.3) i18n (1.8.10) concurrent-ruby (~> 1.0) - jmespath (1.4.0) + jmespath (1.6.1) json (2.5.1) jwt (2.2.3) kramdown (2.3.1) From 9cfd06f8e973800e4179e12d2365597a82c8c17e Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Mon, 13 Jun 2022 00:34:31 +0200 Subject: [PATCH 2/8] deletingAllPathComponents can now handle empty paths (#1018) * Fixes #1012 - deletingAllPathComponents can now handle empty paths --- CHANGELOG.md | 2 ++ .../SwifterSwift/Foundation/URLExtensions.swift | 16 ++++++++++------ Tests/FoundationTests/URLExtensionsTests.swift | 12 ++++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 278241bac..05e2a74ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -121,6 +121,8 @@ The changelog for **SwifterSwift**. Also see the [releases](https://github.com/S - **ColorExtension**: - Fixed a bug: `Color.FlatUI` can be initialized. by [Shiva Huang](https://github.com/ShivaHuang) - Fixed `Color.init?(hexString: String, transparency: CGFloat = 1)` was not handling uppercase `0X` in hex prefix [#947](https://github.com/SwifterSwift/SwifterSwift/pull/947) by [Zero.D.Saber](https://github.com/faimin) +- **URLExtension** + - Fixed `deletingAllPathComponents()` and `deleteAllPathComponents` to handle empty paths, as raised in [#1012](https://github.com/SwifterSwift/SwifterSwift/pull/1012). [#1018](https://github.com/SwifterSwift/SwifterSwift/pull/1018) by [guykogus](https://github.com/guykogus) ### Security diff --git a/Sources/SwifterSwift/Foundation/URLExtensions.swift b/Sources/SwifterSwift/Foundation/URLExtensions.swift index 6b6ab2df3..688f0b200 100644 --- a/Sources/SwifterSwift/Foundation/URLExtensions.swift +++ b/Sources/SwifterSwift/Foundation/URLExtensions.swift @@ -1,4 +1,4 @@ -// URLExtensions.swift - Copyright 2020 SwifterSwift +// URLExtensions.swift - Copyright 2022 SwifterSwift #if canImport(Foundation) import Foundation @@ -14,7 +14,7 @@ public extension URL { /// SwifterSwift: Dictionary of the URL's query parameters. var queryParameters: [String: String]? { guard let components = URLComponents(url: self, resolvingAgainstBaseURL: false), - let queryItems = components.queryItems else { return nil } + let queryItems = components.queryItems else { return nil } var items: [String: String] = [:] @@ -37,11 +37,11 @@ public extension URL { guard let string = string else { return nil } self.init(string: string, relativeTo: url) } - + /** - SwifterSwift: Initializes a forced unwrapped `URL` from string. Can potentially crash if string is invalid. - - Parameter unsafeString: The URL string used to initialize the `URL`object. - */ + SwifterSwift: Initializes a forced unwrapped `URL` from string. Can potentially crash if string is invalid. + - Parameter unsafeString: The URL string used to initialize the `URL`object. + */ init(unsafeString: String) { self.init(string: unsafeString)! } @@ -97,6 +97,8 @@ public extension URL { /// /// - Returns: URL with all path components removed. func deletingAllPathComponents() -> URL { + guard !pathComponents.isEmpty else { return self } + var url: URL = self for _ in 0.. Date: Mon, 13 Jun 2022 09:23:19 +0200 Subject: [PATCH 3/8] Fixes UIView.rotate(toAngle) (#1019) --- CHANGELOG.md | 2 + .../SwifterSwift/UIKit/UIViewExtensions.swift | 11 +-- Tests/UIKitTests/UIViewExtensionsTests.swift | 80 +++++++++---------- Tests/XCTest/XCTestExtensions.swift | 30 ++++++- 4 files changed, 75 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e2a74ab..3f9c41eda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,8 @@ The changelog for **SwifterSwift**. Also see the [releases](https://github.com/S - Fixed a bug:UITextField `addPaddingLeftIcon` doesn't work on iOS 13[#876](https://github.com/SwifterSwift/SwifterSwift/issues/876) by [Jayxiang](https://github.com/Jayxiang) - **UIImage** - Fixed a bug:UIImage `rotated(by:)` lose origin scale, result in image blurred[#904](https://github.com/SwifterSwift/SwifterSwift/pull/904) by [yanpanpan](https://github.com/yanpanpan) +- **UIView** + - Fixed `rotate(toAngle)` to rotate _to_ an angle instead of _by_ an angle, as raised in [#935](https://github.com/SwifterSwift/SwifterSwift/pull/935). [#1019](https://github.com/SwifterSwift/SwifterSwift/pull/1019) by [guykogus](https://github.com/guykogus) - **ColorExtension**: - Fixed a bug: `Color.FlatUI` can be initialized. by [Shiva Huang](https://github.com/ShivaHuang) - Fixed `Color.init?(hexString: String, transparency: CGFloat = 1)` was not handling uppercase `0X` in hex prefix [#947](https://github.com/SwifterSwift/SwifterSwift/pull/947) by [Zero.D.Saber](https://github.com/faimin) diff --git a/Sources/SwifterSwift/UIKit/UIViewExtensions.swift b/Sources/SwifterSwift/UIKit/UIViewExtensions.swift index 1cd2fc951..ae4052025 100755 --- a/Sources/SwifterSwift/UIKit/UIViewExtensions.swift +++ b/Sources/SwifterSwift/UIKit/UIViewExtensions.swift @@ -1,4 +1,4 @@ -// UIViewExtensions.swift - Copyright 2020 SwifterSwift +// UIViewExtensions.swift - Copyright 2022 SwifterSwift #if canImport(UIKit) && !os(watchOS) import UIKit @@ -386,7 +386,7 @@ public extension UIView { completion: ((Bool) -> Void)? = nil) { let angleWithType = (type == .degrees) ? .pi * angle / 180.0 : angle let aDuration = animated ? duration : 0 - UIView.animate(withDuration: aDuration, delay: 0, options: .curveLinear, animations: { () -> Void in + UIView.animate(withDuration: aDuration, delay: 0, options: .curveLinear, animations: { () in self.transform = self.transform.rotated(by: angleWithType) }, completion: completion) } @@ -406,9 +406,10 @@ public extension UIView { duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil) { let angleWithType = (type == .degrees) ? .pi * angle / 180.0 : angle + let currentAngle = atan2(transform.b, transform.a) let aDuration = animated ? duration : 0 UIView.animate(withDuration: aDuration, animations: { - self.transform = self.transform.concatenating(CGAffineTransform(rotationAngle: angleWithType)) + self.transform = self.transform.rotated(by: angleWithType - currentAngle) }, completion: completion) } @@ -425,7 +426,7 @@ public extension UIView { duration: TimeInterval = 1, completion: ((Bool) -> Void)? = nil) { if animated { - UIView.animate(withDuration: duration, delay: 0, options: .curveLinear, animations: { () -> Void in + UIView.animate(withDuration: duration, delay: 0, options: .curveLinear, animations: { () in self.transform = self.transform.scaledBy(x: offset.x, y: offset.y) }, completion: completion) } else { @@ -609,7 +610,7 @@ public extension UIView { func ancestorView(withClass _: T.Type) -> T? { return ancestorView(where: { $0 is T }) as? T } - + /// SwifterSwift: Returns all the subviews of a given type recursively in the /// view hierarchy rooted on the view it its called. /// diff --git a/Tests/UIKitTests/UIViewExtensionsTests.swift b/Tests/UIKitTests/UIViewExtensionsTests.swift index c50cf896f..be45b1df7 100644 --- a/Tests/UIKitTests/UIViewExtensionsTests.swift +++ b/Tests/UIKitTests/UIViewExtensionsTests.swift @@ -1,4 +1,4 @@ -// UIViewExtensionsTests.swift - Copyright 2020 SwifterSwift +// UIViewExtensionsTests.swift - Copyright 2022 SwifterSwift @testable import SwifterSwift import XCTest @@ -254,47 +254,43 @@ final class UIViewExtensionsTests: XCTestCase { func testRotateByAngle() { let view1 = UIView() - let transform1 = CGAffineTransform(rotationAngle: 2) - view1.rotate(byAngle: 2, ofType: .radians, animated: false, duration: 0, completion: nil) - XCTAssertEqual(view1.transform, transform1) + view1.rotate(byAngle: 1, ofType: .radians, animated: false, duration: 0, completion: nil) + XCTAssertEqual(view1.transform, CGAffineTransform(rotationAngle: 1), accuracy: 0.00001) + view1.rotate(byAngle: 1, ofType: .radians, animated: false, duration: 0, completion: nil) + XCTAssertEqual(view1.transform, CGAffineTransform(rotationAngle: 2), accuracy: 0.00001) let view2 = UIView() - let transform2 = CGAffineTransform(rotationAngle: .pi * 90.0 / 180.0) view2.rotate(byAngle: 90, ofType: .degrees, animated: false, duration: 0, completion: nil) - XCTAssertEqual(view2.transform, transform2) + XCTAssertEqual(view2.transform, CGAffineTransform(rotationAngle: .pi / 2.0)) let rotateExpectation = expectation(description: "view rotated") - let view3 = UIView() - let transform3 = CGAffineTransform(rotationAngle: 2) - view3.rotate(byAngle: 2, ofType: .radians, animated: true, duration: 0.5) { _ in rotateExpectation.fulfill() } - XCTAssertEqual(view3.transform, transform3) + XCTAssertEqual(view3.transform, CGAffineTransform(rotationAngle: 2)) waitForExpectations(timeout: 0.5) } func testRotateToAngle() { let view1 = UIView() - let transform1 = CGAffineTransform(rotationAngle: 2) - view1.rotate(toAngle: 2, ofType: .radians, animated: false, duration: 0, completion: nil) - XCTAssertEqual(view1.transform, transform1) + view1.rotate(toAngle: 1, ofType: .radians, animated: false, duration: 0, completion: nil) + XCTAssertEqual(view1.transform, CGAffineTransform(rotationAngle: 1)) + view1.rotate(toAngle: 0, ofType: .radians, animated: false, duration: 0, completion: nil) + XCTAssertEqual(view1.transform, CGAffineTransform(rotationAngle: 0)) let view2 = UIView() - let transform2 = CGAffineTransform(rotationAngle: .pi * 90.0 / 180.0) view2.rotate(toAngle: 90, ofType: .degrees, animated: false, duration: 0, completion: nil) - XCTAssertEqual(view2.transform, transform2) + XCTAssertEqual(view2.transform, CGAffineTransform(rotationAngle: .pi / 2.0)) + view2.rotate(toAngle: 30, ofType: .degrees, animated: false, duration: 0, completion: nil) + XCTAssertEqual(view2.transform, CGAffineTransform(rotationAngle: .pi / 6.0), accuracy: 0.00001) let rotateExpectation = expectation(description: "view rotated") - let view3 = UIView() - let transform3 = CGAffineTransform(rotationAngle: 2) - view3.rotate(toAngle: 2, ofType: .radians, animated: true, duration: 0.5) { _ in rotateExpectation.fulfill() } - XCTAssertEqual(view3.transform, transform3) + XCTAssertEqual(view3.transform, CGAffineTransform(rotationAngle: 2)) waitForExpectations(timeout: 0.5) } @@ -313,7 +309,7 @@ final class UIViewExtensionsTests: XCTestCase { XCTAssertEqual(view1.transform, view2.transform) XCTAssertEqual(view1.transform, view3.transform) } - + #if os(tvOS) func testLoadFromNib() { let bundle = Bundle(for: UIViewExtensionsTests.self) @@ -474,28 +470,28 @@ final class UIViewExtensionsTests: XCTestCase { XCTAssertEqual(buttonSubview.ancestorView(withClass: UITableViewCell.self), tableViewCell) XCTAssertEqual(buttonSubview.ancestorView(withClass: UITableView.self), tableView) } - - func testSubviewsOfType() { - // Test view with subviews with no subviews - XCTAssertEqual(UIView().subviews(ofType: UILabel.self), []) - - // Test view with subviews that have subviews - let parentView = UIView() - - let childView = UIView() - let childViewSubViews = [UILabel(), UIButton(), UITextView(), UILabel(), UIImageView()] - childView.addSubviews(childViewSubViews) - - let childView2 = UIView() - let childView2SubViews = [UISegmentedControl(), UILabel(), UITextView(), UIImageView()] - childView2.addSubviews(childView2SubViews) - - parentView.addSubviews([childView, childView2]) - - let expected = [childViewSubViews[0], childViewSubViews[3], childView2SubViews[1]] - XCTAssertEqual(parentView.subviews(ofType: UILabel.self), expected) - XCTAssertEqual(parentView.subviews(ofType: UITableViewCell.self), []) - } + + func testSubviewsOfType() { + // Test view with subviews with no subviews + XCTAssertEqual(UIView().subviews(ofType: UILabel.self), []) + + // Test view with subviews that have subviews + let parentView = UIView() + + let childView = UIView() + let childViewSubViews = [UILabel(), UIButton(), UITextView(), UILabel(), UIImageView()] + childView.addSubviews(childViewSubViews) + + let childView2 = UIView() + let childView2SubViews = [UISegmentedControl(), UILabel(), UITextView(), UIImageView()] + childView2.addSubviews(childView2SubViews) + + parentView.addSubviews([childView, childView2]) + + let expected = [childViewSubViews[0], childViewSubViews[3], childView2SubViews[1]] + XCTAssertEqual(parentView.subviews(ofType: UILabel.self), expected) + XCTAssertEqual(parentView.subviews(ofType: UITableViewCell.self), []) + } func testFindConstraint() { let view = UIView() diff --git a/Tests/XCTest/XCTestExtensions.swift b/Tests/XCTest/XCTestExtensions.swift index a9d31a032..211e2b3a4 100644 --- a/Tests/XCTest/XCTestExtensions.swift +++ b/Tests/XCTest/XCTestExtensions.swift @@ -1,4 +1,4 @@ -// XCTestExtensions.swift - Copyright 2020 SwifterSwift +// XCTestExtensions.swift - Copyright 2022 SwifterSwift #if canImport(XCTest) import XCTest @@ -45,4 +45,32 @@ public func XCTAssertEqual(_ expression1: @autoclosure () throws -> Color, } #endif +#if canImport(CoreGraphics) +/// SwifterSwift: Asserts that the RGBA values of two `CGAffineTransform`s are equal within a certain accuracy. +/// - Parameters: +/// - expression1: A `CGAffineTransform`. +/// - expression2: A `CGAffineTransform`. +/// - accuracy: Describes the maximum difference between `expression1` and `expression2` for these values to be considered equal. +/// - message: An optional description of the failure. +/// - file: The file in which failure occurred. Defaults to the file name of the test case in which this function was called. +/// - line: The line number on which failure occurred. Defaults to the line number on which this function was called. +public func XCTAssertEqual(_ expression1: @autoclosure () throws -> CGAffineTransform, + _ expression2: @autoclosure () throws -> CGAffineTransform, + accuracy: CGFloat, + _ message: @autoclosure () -> String = "", + file: StaticString = #file, + line: UInt = #line) { + var transform1: CGAffineTransform! + XCTAssertNoThrow(transform1 = try expression1(), message(), file: file, line: line) + var transform2: CGAffineTransform! + XCTAssertNoThrow(transform2 = try expression2(), message(), file: file, line: line) + XCTAssertEqual(transform1.a, transform2.a, accuracy: accuracy, message(), file: file, line: line) + XCTAssertEqual(transform1.b, transform2.b, accuracy: accuracy, message(), file: file, line: line) + XCTAssertEqual(transform1.c, transform2.c, accuracy: accuracy, message(), file: file, line: line) + XCTAssertEqual(transform1.d, transform2.d, accuracy: accuracy, message(), file: file, line: line) + XCTAssertEqual(transform1.tx, transform2.tx, accuracy: accuracy, message(), file: file, line: line) + XCTAssertEqual(transform1.ty, transform2.ty, accuracy: accuracy, message(), file: file, line: line) +} +#endif + #endif From 98cc80d5bbe0cf76a6450ba4dc966a5bbddf9038 Mon Sep 17 00:00:00 2001 From: Guy Kogus Date: Wed, 15 Jun 2022 08:37:48 +0200 Subject: [PATCH 4/8] Project fixes (#1017) * Fix compiling and tests * Cleans up ResourceTests folder to make it more compatible with SPM --- Package.swift | 14 +++--- .../Foundation/DateExtensions.swift | 7 +-- SwifterSwift.xcodeproj/project.pbxproj | 40 ++++++++++++------ .../xcschemes/SwifterSwift-iOS.xcscheme | 2 +- .../xcschemes/SwifterSwift-macOS.xcscheme | 2 +- .../xcschemes/SwifterSwift-tvOS.xcscheme | 2 +- .../xcschemes/SwifterSwift-watchOS.xcscheme | 2 +- .../AppKitTests/NSColorExtensionsTests.swift | 4 +- Tests/MapKitTests/MKMultiPointTests.swift | 3 +- Tests/MapKitTests/MKPolylineTests.swift | 3 +- .../{ => Resources}/TestImage.png | Bin .../{ => Resources}/TestStoryboard.storyboard | 0 .../{ => Resources}/UICollectionViewCell.xib | 0 .../{ => Resources}/UIImageView.xib | 0 .../{ => Resources}/UITableViewCell.xib | 0 .../UITableViewHeaderFooterView.xib | 0 .../big_buck_bunny_720p_1mb.mp4 | Bin .../ResourcesTests/{ => Resources}/test.json | 0 .../tvOS}/TestStoryboard-tvOS.storyboard | 0 .../{ => Resources}/tvOS/UIImageViewTvOS.xib | 0 .../{ => Sources}/MyViewController.swift | 2 +- .../SKSpriteNodeExtensionTests.swift | 11 +++-- .../ArrayExtensionsTests.swift | 11 +++-- .../DictionaryExtensionsTests.swift | 11 +++-- .../UIBezierPathExtensionsTests.swift | 4 +- .../UICollectionViewExtensionsTests.swift | 4 +- Tests/UIKitTests/UIFontExtensionsTests.swift | 10 ++--- Tests/UIKitTests/UIImageExtensionsTests.swift | 7 ++- .../UIViewControllerExtensionsTests.swift | 3 +- 29 files changed, 77 insertions(+), 65 deletions(-) rename Tests/ResourcesTests/{ => Resources}/TestImage.png (100%) rename Tests/ResourcesTests/{ => Resources}/TestStoryboard.storyboard (100%) rename Tests/ResourcesTests/{ => Resources}/UICollectionViewCell.xib (100%) rename Tests/ResourcesTests/{ => Resources}/UIImageView.xib (100%) rename Tests/ResourcesTests/{ => Resources}/UITableViewCell.xib (100%) rename Tests/ResourcesTests/{ => Resources}/UITableViewHeaderFooterView.xib (100%) rename Tests/ResourcesTests/{ => Resources}/big_buck_bunny_720p_1mb.mp4 (100%) rename Tests/ResourcesTests/{ => Resources}/test.json (100%) rename Tests/ResourcesTests/{ => Resources/tvOS}/TestStoryboard-tvOS.storyboard (100%) rename Tests/ResourcesTests/{ => Resources}/tvOS/UIImageViewTvOS.xib (100%) rename Tests/ResourcesTests/{ => Sources}/MyViewController.swift (71%) diff --git a/Package.swift b/Package.swift index e512ee422..8bc6b2774 100644 --- a/Package.swift +++ b/Package.swift @@ -14,14 +14,12 @@ let package = Package( products: [ .library(name: "SwifterSwift", targets: ["SwifterSwift"]) ], - dependencies: [], targets: [ - .target(name: "SwifterSwift", dependencies: []), + .target(name: "SwifterSwift"), .testTarget( - name: "SwifterSwiftTests", - dependencies: ["SwifterSwift"], - path: "Tests", - exclude: ["Info.plist"], - resources: [.process("ResourcesTests")] - ) + name: "SwifterSwiftTests", + dependencies: ["SwifterSwift"], + path: "Tests", + exclude: ["Info.plist"], + resources: [.process("ResourcesTests/Resources")]) ]) diff --git a/Sources/SwifterSwift/Foundation/DateExtensions.swift b/Sources/SwifterSwift/Foundation/DateExtensions.swift index a093ec0a9..ea4457cb9 100755 --- a/Sources/SwifterSwift/Foundation/DateExtensions.swift +++ b/Sources/SwifterSwift/Foundation/DateExtensions.swift @@ -1,4 +1,4 @@ -// DateExtensions.swift - Copyright 2020 SwifterSwift +// DateExtensions.swift - Copyright 2022 SwifterSwift #if canImport(Foundation) import Foundation @@ -49,10 +49,7 @@ public extension Date { public extension Date { /// SwifterSwift: User’s current calendar. - var calendar: Calendar { - // Workaround to segfault on corelibs foundation https://bugs.swift.org/browse/SR-10147 - return Calendar(identifier: Calendar.current.identifier) - } + var calendar: Calendar { Calendar.current } /// SwifterSwift: Era. /// diff --git a/SwifterSwift.xcodeproj/project.pbxproj b/SwifterSwift.xcodeproj/project.pbxproj index d82cfe726..e1553c53d 100644 --- a/SwifterSwift.xcodeproj/project.pbxproj +++ b/SwifterSwift.xcodeproj/project.pbxproj @@ -1417,6 +1417,7 @@ 8D50E51D24D0D6FB00972E2D /* tvOS */ = { isa = PBXGroup; children = ( + F88C491824AF73A400BA0503 /* TestStoryboard-tvOS.storyboard */, 8D50E52024D0D73E00972E2D /* UIImageViewTvOS.xib */, ); path = tvOS; @@ -1483,17 +1484,8 @@ CAC5EBBE2125270A00AB27EC /* ResourcesTests */ = { isa = PBXGroup; children = ( - 8D50E51D24D0D6FB00972E2D /* tvOS */, - CAC5EBC52125270A00AB27EC /* big_buck_bunny_720p_1mb.mp4 */, - CAC5EBC22125270A00AB27EC /* test.json */, - CAC5EBBF2125270A00AB27EC /* TestImage.png */, - CAC5EBC02125270A00AB27EC /* TestStoryboard.storyboard */, - F88C491824AF73A400BA0503 /* TestStoryboard-tvOS.storyboard */, - CAC5EBC12125270A00AB27EC /* UICollectionViewCell.xib */, - 8D50E51E24D0D71E00972E2D /* UIImageView.xib */, - CAC5EBC32125270A00AB27EC /* UITableViewCell.xib */, - CAC5EBC42125270A00AB27EC /* UITableViewHeaderFooterView.xib */, - 5E36CB6424AC9909007727DA /* MyViewController.swift */, + F8830FC3285478EC00C1D802 /* Resources */, + F8830FC2285478EC00C1D802 /* Sources */, ); path = ResourcesTests; sourceTree = ""; @@ -1525,6 +1517,30 @@ path = CoreAnimationTests; sourceTree = ""; }; + F8830FC2285478EC00C1D802 /* Sources */ = { + isa = PBXGroup; + children = ( + 5E36CB6424AC9909007727DA /* MyViewController.swift */, + ); + path = Sources; + sourceTree = ""; + }; + F8830FC3285478EC00C1D802 /* Resources */ = { + isa = PBXGroup; + children = ( + 8D50E51D24D0D6FB00972E2D /* tvOS */, + CAC5EBC52125270A00AB27EC /* big_buck_bunny_720p_1mb.mp4 */, + CAC5EBC22125270A00AB27EC /* test.json */, + CAC5EBBF2125270A00AB27EC /* TestImage.png */, + CAC5EBC02125270A00AB27EC /* TestStoryboard.storyboard */, + CAC5EBC12125270A00AB27EC /* UICollectionViewCell.xib */, + 8D50E51E24D0D71E00972E2D /* UIImageView.xib */, + CAC5EBC32125270A00AB27EC /* UITableViewCell.xib */, + CAC5EBC42125270A00AB27EC /* UITableViewHeaderFooterView.xib */, + ); + path = Resources; + sourceTree = ""; + }; F8E62DA224D0184E00BF35AE /* XCTestTests */ = { isa = PBXGroup; children = ( @@ -1719,7 +1735,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0900; - LastUpgradeCheck = 1250; + LastUpgradeCheck = 1340; ORGANIZATIONNAME = SwifterSwift; TargetAttributes = { 07898B5C1F278D7600558C97 = { diff --git a/SwifterSwift.xcodeproj/xcshareddata/xcschemes/SwifterSwift-iOS.xcscheme b/SwifterSwift.xcodeproj/xcshareddata/xcschemes/SwifterSwift-iOS.xcscheme index 94570c0b0..6ce19705a 100644 --- a/SwifterSwift.xcodeproj/xcshareddata/xcschemes/SwifterSwift-iOS.xcscheme +++ b/SwifterSwift.xcodeproj/xcshareddata/xcschemes/SwifterSwift-iOS.xcscheme @@ -1,6 +1,6 @@ UIModalPresentationStyle { return .popover From 89950541ce385422d12cef0f51d0ef6db3389ada Mon Sep 17 00:00:00 2001 From: Omar Albeik <8127757+omaralbeik@users.noreply.github.com> Date: Thu, 30 Jun 2022 09:32:27 +0200 Subject: [PATCH 5/8] Update CONTRIBUTING.md (#1024) - Fix typos - Add examples for allowed/disallowed code - Remove changelog entry to lower entry friction for new joiners --- CONTRIBUTING.md | 306 ++++++++++++++++++++++++++++++------------------ 1 file changed, 195 insertions(+), 111 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 837c59472..12cf48352 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,9 +7,6 @@ This document contains information and guidelines about contributing to this pro - [Asking Questions](#asking-questions) - [Ways to Contribute](#ways-to-contribute) - [Adding new Extensions](#adding-new-extensions) -- [Adding Tests](#adding-tests) -- [Adding documentation](#adding-documentation) -- [Adding changelog entries](#adding-changelog-entries) - [Reporting Issues](#reporting-issues) --- @@ -17,7 +14,7 @@ This document contains information and guidelines about contributing to this pro ## Asking Questions We don't use GitHub as a support forum. -For any usage questions that are not specific to the project itself, please ask on [Stack Overflow](https://stackoverflow.com) instead with the tag SwifterSwift. +For any usage questions that are not specific to the project itself, please ask on [Stack Overflow](https://stackoverflow.com) instead, with the tag SwifterSwift. By doing so, you'll be more likely to quickly solve your problem, and you'll allow anyone else with the same question to find the answer. This also allows us to focus on improving the project for others. @@ -30,7 +27,7 @@ You can contribute to the project in a variety of ways: - Improve documentation 🙏 - Add more extensions 👍 - Add missing unit tests 😅 -- Fixing or reporting bugs 😱 +- Fix or report bugs 😱 If you're new to Open Source or Swift the SwifterSwift community is a great place to get involved. @@ -42,157 +39,245 @@ If you're new to Open Source or Swift the SwifterSwift community is a great plac Please refer to the following rules before submitting a pull request with your new extensions: -- Make sure no similar extension already exist in SwifterSwift. -- Add your contributions to [**master branch**](https://github.com/SwifterSwift/SwifterSwift/tree/master): - - by doing this we can merge new pull-requests into **master** branch as soon as they are accepted, and add them to the next releases once they are fully tested. -- Mention the original source of extension source (if possible) as a comment inside extension: +- Make sure no similar extension already exists in SwifterSwift. +- Add your contributions to [**master branch**](https://github.com/SwifterSwift/SwifterSwift/tree/master), by doing so we can merge new pull requests as soon as they are accepted, and add them to the next releases once they are fully tested. +- A pull request should preferably only add **one extension** at a time. - ```swift -public extension SomeType { +For an extension to be suitable for SwifterSwift, it has to fulfill the following conditions: - public name: SomeType { - // https://stackoverflow.com/somepage - // .. code +### 1. Clarity +- Extension names should be in English and as clear as possible. +- Code should be readable and easy to reason about. Refer to [Swift’s API Design Guidelines]([https://www.swift.org/documentation/api-design-guidelines/](https://www.swift.org/documentation/api-design-guidelines/)) for more details. + +### 2. No dependencies +- We do not allow 3rd party dependencies in SwifterSwift. +- Extensions can not rely on each other. We prefer code duplication over-abstraction in this project. That makes it easier to reason about a single extension individually. +- Ideally, copy-pasting any single extension into another codebase should be possible. + +Allowed: + +```swift +public extension Foo { + var bar: Bar { ... } +} +``` + +Not allowed: + +```swift +public extension Foo { + func bar() -> Bar { /* ... */ } + func baz() { + let bar = bar() + // ... + } +} +``` + +### 3. Public extensions +- Extension should be **public**: + +Example: +```swift +public extension Foo { + var bar: Bar { ... } +} +``` + +- Avoid adding unnecessary `public` keywords for unites in an extension: + +```swift +public extension Foo { + public var bar: Bar { ... } +} +``` + +### 4. Examples of allowed code +- Basically, anything that can be expressed in a single extension and does not expose a new type is allowed. + +Examples where `Foo` is the extended type: + +Get-only property: +```swift +public extension Foo { + var bar: Bar { + // ... } +} +``` +Static get-only property: + +```swift +public extension Foo { + static var bar: Bar { + // ... + } } - ``` - -- A pull request should only add one extension at a time. -- Do not use an existing SwifterSwift extension inside another SwifterSwift extension. All extensions should be able to be copied and pasted and work immediately without having to copy another extension. -- All extensions should follow [Swift API Design Guidelines](https://developer.apple.com/videos/play/wwdc2016/403/) -- Always declare extensions as **public**. -- All extensions names should be as clear as possible. -- All extensions should be well documented. see [Adding documentation](#adding-documentation) -- Avoid using custom classes and objects the goal for this library is to extend the standards types available natively in Swift, iOS, macOS, watchOS, tvOS and Linux. -- Extensions could be: - - Enums - - Instance properties & type properties - - Instance methods & type methods - - Initializers - - Structs -- All extensions should be tested. See [Adding Tests](#adding-tests) to know more. -- Files are named based on the type that the contained extensions extend. - - (example: all String extensions are found in "**StringExtensions.swift**" file) -- Add [subspec](https://github.com/SwifterSwift/SwifterSwift/blob/master/SwifterSwift.podspec) if you submit extensions for a module that is not presented in podspec file yet. -- Extensions and tests are ordered inside files in the following order: - -```swift -// MARK: - enums -public enum { - // ... +``` + +Get/set property: + +```swift +public extension Foo { + var bar: Bar { + get { /* ... */ } + set { /* ... */ } + + } } +``` -// MARK: - Properties -public extension SomeType {} +Static get/set property: -// MARK: - Methods -public extension SomeType {} +```swift +public extension Foo { + static var bar: Bar { + get { /* ... */ } + set { /* ... */ } -// MARK: - Initializers -public extension SomeType {} + } +} ``` ---- +Method: -## Adding Tests +```swift +public extension Foo { + func bar() { + // ... + } +} +``` -Please follow these guidelines before submitting a pull request with new tests: +Static method: -- Every extended SwifterSwift type should have one specific subclass of XCTestCase. -- There should be a one to one relationship between methods/properties and their backing tests. -- Tests should be named using the same API of the extension it backs. - - (example: `DateExtensions` method `isBetween` is named `testIsBetween`) -- All test files are named based on the extensions which it tests. - - (example: all String extensions tests are found in "**StringExtensionsTests.swift**" file) -- The subclass should be marked as final. -- All extensions files and test files have a one to one relationship. - - (example: all tests for "**StringExtensions.swift**" are found in the "**StringExtensionsTests.swift**" file) -- SwifterSwift source files should not be added to the test target directly, but you should rather import SwifterSwift into the test target by using: @testable import SwifterSwift -- Tests are ordered inside files in the same order as extensions. See [Adding new Extensions](#adding-new-extensions) to know more. +```swift +public extension Foo { + static func bar() { + // ... + } +} +``` ---- +Initializer: -## Adding documentation +```swift +public extension Foo { + init(bar: Bar) { + // ... + } +} +``` -Use the following template to add documentation for extensions -> Replace placeholders inside <> +Failable initializer: -> Remove any extra lines, eg. if method does not return any value, delete the `- Returns:` line +```swift +public extension Foo { + init?(bar: Bar) { + // ... + } +} +``` -### Documentation template for units with single parameter +Operators and precedence groups: ```swift -/// SwifterSwift: . -/// -/// -/// -/// - Parameter : . -/// - Throws: -/// - Returns: +precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence } +infix operator **: PowerPrecedence +public func ** (x: Decimal, y: Int) -> Decimal { + return pow(x, y) +} +``` + +### 5. Examples of disallowed code +- Introducing new types, including protocols, classes, actors, structs, or enums. +- Protocol conformance. Example: + +```swift +extension Foo: Codable { + // ... +} +``` + +- Global functions (except operators): + +```swift +public func bar() { + // ... +} ``` -### Documentation template for units with multiple parameters +- Introducing new types in an extension: + +```swift +public extension Foo { + struct Bar { + // ... + } +} +``` + +### 6. Documentation +- Extensions should be well documented with an example —if possible—. +- Documentation should always start with the prefix **SwifterSwift:** +- Extensions should be fully documented in English and as clear as possible. +- In Xcode select the extension and use the shortcut `command` + `alt` + `/` to create a documentation template. or use the following template: ```swift /// SwifterSwift: . /// /// /// -/// - Parameters: -/// - : . -/// - : . +/// - Parameter : . /// - Throws: /// - Returns: ``` -### Documentation template for enums +- Mention the source —if possible— as a comment inside the extension: ```swift -/// SwifterSwift: . -/// -/// - : -/// - : -/// - : -/// - : +public extension Foo { + var bar: Bar { + // https://stackoverflow.com/... + // ... + } +} ``` -### Documentation Examples +### 7. Tested +- Every extended type should have a matching test case. Example: -```swift +For the following extension of type `Bar` defined in framework `Foo`: -/// SwifterSwift: Sum of all elements in array. -/// -/// [1, 2, 3, 4, 5].sum() -> 15 -/// -/// - Returns: Sum of the array's elements. -func sum() -> Element { - // ... -} +> Sources/Foo/BarExtensions.swift -/// SwifterSwift: Date by changing value of calendar component. -/// -/// - Parameters: -/// - component: component type. -/// - value: new value of component to change. -/// - Returns: original date after changing given component to given value. -func changing(_ component: Calendar.Component, value: Int) -> Date? { - // ... -} +```swift +import Foo +public extension Bar { + var baz: Baz { /* ... */ } +} ``` -### Power Tip +The matching test case is: -In Xcode select a method and press `command` + `alt` + `/` to create a documentation template! +> Tests/Foo/BarExtensionsTests.swift ---- - -## Adding changelog entries +```swift +import Foo -The [Changelog](https://github.com/SwifterSwift/SwifterSwift/blob/master/CHANGELOG.md) is a file which contains a curated, chronologically ordered list of notable changes for each version of a project. Please make sure to add a changelog entry describing your contribution to it every time there is a notable change. +final class BarExtensionsTests: XCTestCase { + func testBaz() { + // ... + } +} +``` -The [Changelog Guidelines](https://github.com/SwifterSwift/SwifterSwift/blob/master/CHANGELOG_GUIDELINES.md) contains instructions for maintaining (or adding new entries) to the Changelog. +- There should be a one to one relationship between methods/properties and their backing tests. +- Tests should be named using the same API of the extension it backs, example: `DateExtensions`'s method `isBetween` is named `testIsBetween`. +- Test case classes should be marked as final. +- SwifterSwift source files should not be added to the test target directly, but you should rather import SwifterSwift into the test target by using: `@testable import SwifterSwift` --- @@ -202,8 +287,7 @@ A great way to contribute to the project is to send a detailed issue when you en We always appreciate a well-written, thorough bug report. Check that the project [issues page](https://github.com/SwifterSwift/SwifterSwift/issues) doesn't already include that problem or suggestion before submitting an issue. -If you find a match, add a quick "**+1**" or "**I have this problem too**". -Doing this helps prioritize the most common problems and requests. +If you find a match, add a quick "**+1**" or "**I have this problem too**". Doing this helps prioritize the most common problems and requests. **When reporting issues, please include the following:** From 01d7e67082c06ca1a092a4a749a885040946a32b Mon Sep 17 00:00:00 2001 From: Marco Eidinger Date: Wed, 13 Jul 2022 05:17:10 -0700 Subject: [PATCH 6/8] hexString computed property for CryptoKit.Digest (#1026) * hexString computed property for CryptoKit.Digest * Update Sources/SwifterSwift/CryptoKit/DigestExtensions.swift Co-authored-by: Luciano Almeida * Improvements to DigestExtensions per code review Co-authored-by: Luciano Almeida --- CHANGELOG.md | 2 ++ README.md | 11 ++++++ .../CryptoKit/DigestExtensions.swift | 20 +++++++++++ SwifterSwift.podspec | 5 +++ SwifterSwift.xcodeproj/project.pbxproj | 34 +++++++++++++++++++ .../DigestExtensionsTests.swift | 17 ++++++++++ 6 files changed, 89 insertions(+) create mode 100644 Sources/SwifterSwift/CryptoKit/DigestExtensions.swift create mode 100644 Tests/CryptoKitTests/DigestExtensionsTests.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f9c41eda..950642eda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,8 @@ The changelog for **SwifterSwift**. Also see the [releases](https://github.com/S - Added `Array.joined(separator:)` to create a new `NSAttributedString` by concatenating the elements of the sequence, adding the given separator between each element. [#985](https://github.com/SwifterSwift/SwifterSwift/pull/985) by [Roman Podymov](https://github.com/RomanPodymov). - **UIButton** - Added `setAttributedTitleForAllStates`, `attributedTitleForDisabled`, `attributedTitleForHighlighted`, `attributedTitleForNormal` and `attributedTitleForSelected` for convenient work with attributed strings. [#1001](https://github.com/SwifterSwift/SwifterSwift/pull/1001) by [Roman Podymov](https://github.com/RomanPodymov). +- **Digest** + - Added `hexString` to get a hexadecimal representation for all digest typed in `CryptoKit` (e.g. `SHA216Digest`, `SHA512Digest`,`MD5Digest`, ...). [#1026](https://github.com/SwifterSwift/SwifterSwift/pull/1026) by [Marco Eidinger](https://github.com/MarcoEidinger). ### Changed - **NSAttributedString**: diff --git a/README.md b/README.md index adfc6c8f2..3f730ff1d 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,9 @@ SwifterSwift is Swift v5.0+ compatible starting from v5

- Integrate CoreLocation extensions only:

pod 'SwifterSwift/CoreLocation'
+

- Integrate CryptoKit extensions only:

+
pod 'SwifterSwift/CryptoKit'
+

- Integrate SpriteKit extensions only:

pod 'SwifterSwift/SpriteKit'
@@ -262,6 +265,14 @@ let package = Package( +
+CryptoKit Extensions +
+ +
+
MapKit Extensions
diff --git a/Sources/SwifterSwift/CryptoKit/DigestExtensions.swift b/Sources/SwifterSwift/CryptoKit/DigestExtensions.swift new file mode 100644 index 000000000..2c3bc448b --- /dev/null +++ b/Sources/SwifterSwift/CryptoKit/DigestExtensions.swift @@ -0,0 +1,20 @@ +// DigestExtensions.swift - Copyright 2022 SwifterSwift + +#if canImport(CryptoKit) +import CryptoKit + +@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) +public extension Digest { + + // MARK: - Properties + + /// SwifterSwift: Hexadecimal value string (read-only, Complexity: O(N), _N_ being the amount of bytes.) + var hexString: String { + var result = "" + for byte in self { + result += String(format: "%02X", byte) + } + return result + } +} +#endif diff --git a/SwifterSwift.podspec b/SwifterSwift.podspec index c3f7f6d09..b1de1d212 100644 --- a/SwifterSwift.podspec +++ b/SwifterSwift.podspec @@ -58,6 +58,11 @@ Pod::Spec.new do |s| sp.source_files = 'Sources/SwifterSwift/Shared/*.swift', 'Sources/SwifterSwift/CoreAnimation/*.swift' end + # CryptoKit Extensions + s.subspec 'CryptoKit' do |sp| + sp.source_files = 'Sources/SwifterSwift/Shared/*.swift', 'Sources/SwifterSwift/CryptoKit/*.swift' + end + # MapKit Extensions s.subspec 'MapKit' do |sp| sp.source_files = 'Sources/SwifterSwift/Shared/*.swift', 'Sources/SwifterSwift/MapKit/*.swift' diff --git a/SwifterSwift.xcodeproj/project.pbxproj b/SwifterSwift.xcodeproj/project.pbxproj index e1553c53d..5566d47cc 100644 --- a/SwifterSwift.xcodeproj/project.pbxproj +++ b/SwifterSwift.xcodeproj/project.pbxproj @@ -435,6 +435,13 @@ 784C75392051BE1D001C48DD /* MKPolylineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784C75362051BE1D001C48DD /* MKPolylineTests.swift */; }; 86B3F7AC208D3D5C00BC297B /* UIScrollViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86B3F7AB208D3D5C00BC297B /* UIScrollViewExtensions.swift */; }; 86B3F7AE208D3DF300BC297B /* UIScrollViewExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86B3F7AD208D3DF300BC297B /* UIScrollViewExtensionsTests.swift */; }; + 8AC39B6328790A6B0041A56C /* DigestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6228790A6B0041A56C /* DigestExtensions.swift */; }; + 8AC39B6428790A6B0041A56C /* DigestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6228790A6B0041A56C /* DigestExtensions.swift */; }; + 8AC39B6528790A6B0041A56C /* DigestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6228790A6B0041A56C /* DigestExtensions.swift */; }; + 8AC39B6628790A6B0041A56C /* DigestExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6228790A6B0041A56C /* DigestExtensions.swift */; }; + 8AC39B6928790B5F0041A56C /* DigestExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6828790B5F0041A56C /* DigestExtensionsTests.swift */; }; + 8AC39B6A28790B5F0041A56C /* DigestExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6828790B5F0041A56C /* DigestExtensionsTests.swift */; }; + 8AC39B6B28790B5F0041A56C /* DigestExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AC39B6828790B5F0041A56C /* DigestExtensionsTests.swift */; }; 8D4B424C212972AE002A5923 /* UILayoutPriorityExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4B424B212972AE002A5923 /* UILayoutPriorityExtensions.swift */; }; 8D4B424D212972AE002A5923 /* UILayoutPriorityExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4B424B212972AE002A5923 /* UILayoutPriorityExtensions.swift */; }; 8D4B424F212972E7002A5923 /* UILayoutPriorityExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D4B424E212972E7002A5923 /* UILayoutPriorityExtensionsTests.swift */; }; @@ -844,6 +851,8 @@ 784C75362051BE1D001C48DD /* MKPolylineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MKPolylineTests.swift; sourceTree = ""; }; 86B3F7AB208D3D5C00BC297B /* UIScrollViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIScrollViewExtensions.swift; sourceTree = ""; }; 86B3F7AD208D3DF300BC297B /* UIScrollViewExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIScrollViewExtensionsTests.swift; sourceTree = ""; }; + 8AC39B6228790A6B0041A56C /* DigestExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigestExtensions.swift; sourceTree = ""; }; + 8AC39B6828790B5F0041A56C /* DigestExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigestExtensionsTests.swift; sourceTree = ""; }; 8D4B424B212972AE002A5923 /* UILayoutPriorityExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILayoutPriorityExtensions.swift; sourceTree = ""; }; 8D4B424E212972E7002A5923 /* UILayoutPriorityExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UILayoutPriorityExtensionsTests.swift; sourceTree = ""; }; 8D50E51E24D0D71E00972E2D /* UIImageView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = UIImageView.xib; sourceTree = ""; }; @@ -1093,6 +1102,7 @@ E5E5EB382350EE9A00B04C42 /* CoreAnimation */, 07D8960D1F5ED85400FC894D /* CoreGraphics */, 07D8960C1F5ED84400FC894D /* CoreLocation */, + 8AC39B6128790A150041A56C /* CryptoKit */, 664CB981217243BA00FC87B4 /* Dispatch */, 07B7F1651F5EB41600E6F910 /* Foundation */, 0DAEBCDE24B0041900F61684 /* HealthKit */, @@ -1186,6 +1196,7 @@ E5E5EB3B2350F39E00B04C42 /* CoreAnimationTests */, 07D8960E1F5ED89A00FC894D /* CoreGraphicsTests */, 07D8960F1F5ED8AB00FC894D /* CoreLocationTests */, + 8AC39B6728790B330041A56C /* CryptoKitTests */, 664CB98821724A3A00FC87B4 /* DispatchTests */, 07C50CF91F5EB03200F46E5A /* FoundationTests */, 0DAEBCE124B0077000F61684 /* HealthKitTests */, @@ -1414,6 +1425,22 @@ path = MapKitTests; sourceTree = ""; }; + 8AC39B6128790A150041A56C /* CryptoKit */ = { + isa = PBXGroup; + children = ( + 8AC39B6228790A6B0041A56C /* DigestExtensions.swift */, + ); + path = CryptoKit; + sourceTree = ""; + }; + 8AC39B6728790B330041A56C /* CryptoKitTests */ = { + isa = PBXGroup; + children = ( + 8AC39B6828790B5F0041A56C /* DigestExtensionsTests.swift */, + ); + path = CryptoKitTests; + sourceTree = ""; + }; 8D50E51D24D0D6FB00972E2D /* tvOS */ = { isa = PBXGroup; children = ( @@ -2075,6 +2102,7 @@ E5E5EB3A2350EED400B04C42 /* CAGradientLayerExtensions.swift in Sources */, 07B7F2121F5EB43C00E6F910 /* DoubleExtensions.swift in Sources */, 07B7F2171F5EB43C00E6F910 /* OptionalExtensions.swift in Sources */, + 8AC39B6328790A6B0041A56C /* DigestExtensions.swift in Sources */, 9D806A792258E6A0008E500A /* SCNCapsuleExtensions.swift in Sources */, 074EAF1B1F7BA68B00C74636 /* UIFontExtensions.swift in Sources */, 8D4B424C212972AE002A5923 /* UILayoutPriorityExtensions.swift in Sources */, @@ -2174,6 +2202,7 @@ 17A4B79426CCFFAF007D299F /* SKSpriteNodeExtensions.swift in Sources */, 07B7F1AD1F5EB42000E6F910 /* UIImageExtensions.swift in Sources */, 9D806A372258AE09008E500A /* UIBezierPathExtensions.swift in Sources */, + 8AC39B6428790A6B0041A56C /* DigestExtensions.swift in Sources */, 077BA08B1F6BE81F00D9C4AC /* URLRequestExtensions.swift in Sources */, 07A1C448224FFE16003272E4 /* UIApplicationExtensions.swift in Sources */, F854D2C42423ECF0003A08A9 /* CATransform3DExtensions.swift in Sources */, @@ -2288,6 +2317,7 @@ 074EAF1D1F7BA68B00C74636 /* UIFontExtensions.swift in Sources */, 18C8E5E02074C60C00F8AF51 /* SequenceExtensions.swift in Sources */, 07B7F1BE1F5EB42200E6F910 /* UIAlertControllerExtensions.swift in Sources */, + 8AC39B6528790A6B0041A56C /* DigestExtensions.swift in Sources */, 07B7F2281F5EB45100E6F910 /* CGColorExtensions.swift in Sources */, 70269A2E1FB478D100C6C2D0 /* CalendarExtensions.swift in Sources */, 07B7F1F21F5EB43B00E6F910 /* LocaleExtensions.swift in Sources */, @@ -2319,6 +2349,7 @@ 07B7F1DE1F5EB43B00E6F910 /* FloatingPointExtensions.swift in Sources */, 07B7F1DB1F5EB43B00E6F910 /* DictionaryExtensions.swift in Sources */, A9AEB78820283ACD0021AACF /* FileManagerExtensions.swift in Sources */, + 8AC39B6628790A6B0041A56C /* DigestExtensions.swift in Sources */, 07B7F1DC1F5EB43B00E6F910 /* DoubleExtensions.swift in Sources */, 07B7F1D71F5EB43B00E6F910 /* CharacterExtensions.swift in Sources */, 9DC844A62349E27600E1571A /* NSColorExtensions.swift in Sources */, @@ -2465,6 +2496,7 @@ 7832C2B4209BB32500224EED /* ComparableExtensionsTests.swift in Sources */, 182698AC1F8AB46E0052F21E /* CGColorExtensionsTests.swift in Sources */, 17A4B79826CD0DA2007D299F /* SKSpriteNodeExtensionTests.swift in Sources */, + 8AC39B6928790B5F0041A56C /* DigestExtensionsTests.swift in Sources */, 07C50D8F1F5EB06000F46E5A /* CLLocationExtensionsTests.swift in Sources */, 9D806A972258FD81008E500A /* SCNCylinderExtensionsTests.swift in Sources */, 07C50D8D1F5EB06000F46E5A /* CGPointExtensionsTests.swift in Sources */, @@ -2592,6 +2624,7 @@ 07C50D8B1F5EB06000F46E5A /* NSAttributedStringExtensionsTests.swift in Sources */, 18C8E5E42074C67000F8AF51 /* SequenceExtensionsTests.swift in Sources */, 07A494EC23C7D60300DFCBFC /* CLVisitExtensionsTests.swift in Sources */, + 8AC39B6A28790B5F0041A56C /* DigestExtensionsTests.swift in Sources */, 07C50D511F5EB04700F46E5A /* UITabBarExtensionsTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2625,6 +2658,7 @@ F8C1AE76225B871F0045D5A0 /* NSRegularExpressionExtensionsTests.swift in Sources */, 07C50D791F5EB05100F46E5A /* DictionaryExtensionsTests.swift in Sources */, C7E027CB2360958B00F1061E /* KeyedDecodingContainerExtensionsTests.swift in Sources */, + 8AC39B6B28790B5F0041A56C /* DigestExtensionsTests.swift in Sources */, 07C50D7B1F5EB05100F46E5A /* FloatExtensionsTests.swift in Sources */, 07C50D7F1F5EB05100F46E5A /* StringExtensionsTests.swift in Sources */, 70269A311FB47B0C00C6C2D0 /* CalendarExtensionTest.swift in Sources */, diff --git a/Tests/CryptoKitTests/DigestExtensionsTests.swift b/Tests/CryptoKitTests/DigestExtensionsTests.swift new file mode 100644 index 000000000..87feb0c28 --- /dev/null +++ b/Tests/CryptoKitTests/DigestExtensionsTests.swift @@ -0,0 +1,17 @@ +// DigestExtensionsTests.swift - Copyright 2022 SwifterSwift + +@testable import SwifterSwift +import XCTest + +#if canImport(CryptoKit) +import CryptoKit + +final class DigestExtensionsTests: XCTestCase { + @available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 13.0, *) + func testHexString() { + guard let data = "Hello, World!".data(using: .utf8) else { return } + XCTAssertEqual(SHA256.hash(data: data).hexString, "DFFD6021BB2BD5B0AF676290809EC3A53191DD81C7F70A4B28688A362182986F") + XCTAssertEqual(SHA512.hash(data: data).hexString, "374D794A95CDCFD8B35993185FEF9BA368F160D8DAF432D08BA9F1ED1E5ABE6CC69291E0FA2FE0006A52570EF18C19DEF4E617C33CE52EF0A6E5FBE318CB0387") + } +} +#endif From 933f27d8e7fa0bf8200a5d6235e0de383b801126 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Jul 2022 00:14:19 -0300 Subject: [PATCH 7/8] Bump tzinfo from 1.2.9 to 1.2.10 (#1028) Bumps [tzinfo](https://github.com/tzinfo/tzinfo) from 1.2.9 to 1.2.10. - [Release notes](https://github.com/tzinfo/tzinfo/releases) - [Changelog](https://github.com/tzinfo/tzinfo/blob/master/CHANGES.md) - [Commits](https://github.com/tzinfo/tzinfo/compare/v1.2.9...v1.2.10) --- updated-dependencies: - dependency-name: tzinfo dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6966e1767..d6fc4828d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -284,7 +284,7 @@ GEM tty-cursor (~> 0.7) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.9) + tzinfo (1.2.10) thread_safe (~> 0.1) uber (0.1.0) unf (0.1.4) From a28621182ddc07496f5a4a3c071c0e07f1500579 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Tue, 9 Aug 2022 22:23:03 -0300 Subject: [PATCH 8/8] Removing Xctool from project (#1035) --- Brewfile | 1 - Brewfile.lock.json | 50 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Brewfile b/Brewfile index 74666d3d5..f2fbe62be 100644 --- a/Brewfile +++ b/Brewfile @@ -1,2 +1 @@ brew "swiftformat" -brew "xctool" diff --git a/Brewfile.lock.json b/Brewfile.lock.json index 2a7e2de65..0eac37b89 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -2,22 +2,40 @@ "entries": { "brew": { "swiftformat": { - "version": "0.47.0", + "version": "0.49.14", "bottle": { - "cellar": ":any_skip_relocation", - "prefix": "/usr/local", + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", "files": { - "catalina": { - "url": "https://homebrew.bintray.com/bottles/swiftformat-0.47.0.catalina.bottle.tar.gz", - "sha256": "81431257faa84ed092b02dbcaa5703e2759d915cb18c3a7c8f663311cbd2d79e" + "arm64_monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:7f8d9c244ced7e092cb18af0a36e1b64414e28dfbbc18beabe25fe0080aa3bca", + "sha256": "7f8d9c244ced7e092cb18af0a36e1b64414e28dfbbc18beabe25fe0080aa3bca" }, - "mojave": { - "url": "https://homebrew.bintray.com/bottles/swiftformat-0.47.0.mojave.bottle.tar.gz", - "sha256": "af859141fb9f4ecf149a4f905cca94381fb64aaddcb3a113b0f1ff1fe5d9e5b3" + "arm64_big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:f1c062ceb1c7d933edb1e94f0cb1cb1b79b33821d565d26ebfbdf805def3b8f9", + "sha256": "f1c062ceb1c7d933edb1e94f0cb1cb1b79b33821d565d26ebfbdf805def3b8f9" }, - "high_sierra": { - "url": "https://homebrew.bintray.com/bottles/swiftformat-0.47.0.high_sierra.bottle.tar.gz", - "sha256": "6842c5c972883b6c176cf02fa8dd12b09663889369b1c9ef18201d594120b642" + "monterey": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:a3242f98aee8736737fac5091c35ed34532c6e9a7ec66532e9418731b12ce158", + "sha256": "a3242f98aee8736737fac5091c35ed34532c6e9a7ec66532e9418731b12ce158" + }, + "big_sur": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:76d9cd1efe09137f656c94c6498b80c2d9d7ca1f9cbd5a98d0699aa15629bd52", + "sha256": "76d9cd1efe09137f656c94c6498b80c2d9d7ca1f9cbd5a98d0699aa15629bd52" + }, + "catalina": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:ac73b68d0225d794f415d5aedf0e2ffdbd1251e68e874a95f43c43431eeac518", + "sha256": "ac73b68d0225d794f415d5aedf0e2ffdbd1251e68e874a95f43c43431eeac518" + }, + "x86_64_linux": { + "cellar": "/home/linuxbrew/.linuxbrew/Cellar", + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:89ba5a1898f9e5ce08582cd56399d18713c4091cb2b56a91ef839420dae49096", + "sha256": "89ba5a1898f9e5ce08582cd56399d18713c4091cb2b56a91ef839420dae49096" } } } @@ -54,6 +72,14 @@ "CLT": "", "Xcode": "12.3", "macOS": "11.0.1" + }, + "monterey": { + "HOMEBREW_VERSION": "3.5.8", + "HOMEBREW_PREFIX": "/opt/homebrew", + "Homebrew/homebrew-core": "802096aba4fdaa0d3cd080a2354cbce4dbe4044f", + "CLT": "13.4.0.0.1.1651278267", + "Xcode": "13.4.1", + "macOS": "12.5" } } }