From bbbfd0be1507946d4b5054274bf45b94aca8ac38 Mon Sep 17 00:00:00 2001 From: Christopher Fuller Date: Tue, 12 Dec 2023 13:31:04 -0800 Subject: [PATCH 1/4] Upgrade rules_apple v3.1.1 and use ios_build_test (#257) --- .bazelversion | 1 + .github/workflows/bazel.yml | 2 +- BUILD.bazel | 12 ++++++++++-- WORKSPACE.bazel | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .bazelversion diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 00000000..66ce77b7 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +7.0.0 diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 1da58932..e7a62e8b 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -17,4 +17,4 @@ jobs: - name: Checkout source uses: actions/checkout@v3 - name: Build - run: bazelisk build --apple_platform_type=ios --cpu=ios_x86_64 //:Layout + run: bazelisk build --noenable_bzlmod //:all diff --git a/BUILD.bazel b/BUILD.bazel index fe7647dd..1a81f322 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,8 +1,16 @@ +load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test") load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") +ios_build_test( + name = "Layout-iOS", + minimum_os_version = "13.0", + targets = [":Layout"], +) + swift_library( name = "Layout", - module_name = "Layout", - srcs = glob(["Sources/Layout/**/*.swift"], allow_empty = False), + srcs = glob(["Sources/Layout/**/*.swift"]), + copts = ["-strict-concurrency=complete"], visibility = ["//visibility:public"], + tags = ["manual"], ) diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index b7013e72..4755b328 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -2,8 +2,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "build_bazel_rules_apple", - sha256 = "8ac4c7997d863f3c4347ba996e831b5ec8f7af885ee8d4fe36f1c3c8f0092b2c", - url = "https://github.com/bazelbuild/rules_apple/releases/download/2.5.0/rules_apple.2.5.0.tar.gz", + sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7", + url = "https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz", ) load( From caa8c9777e5788370f7060baf96f777e7848d149 Mon Sep 17 00:00:00 2001 From: Christopher Fuller Date: Tue, 12 Dec 2023 16:13:23 -0800 Subject: [PATCH 2/4] Remove extraneous `@testable` (#253) --- Tests/LayoutTests/Attributes/CanonicalEdgeTests.swift | 2 +- Tests/LayoutTests/Attributes/DirectionalEdgeTests.swift | 2 +- Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift | 2 +- Tests/LayoutTests/Builders/LayoutBuilderTests.swift | 2 +- .../LayoutItem/LayoutItems/UIView+LayoutItemTests.swift | 2 +- Tests/LayoutTests/LayoutItemTests.swift | 2 +- Tests/LayoutTests/Swift/ArrayTests.swift | 2 +- Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift | 2 +- Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift | 2 +- Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift | 2 +- Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift | 2 +- Tests/LayoutTests/UIKit/UILayoutGuideTests.swift | 2 +- Tests/LayoutTests/UIKit/UILayoutPriorityTests.swift | 2 +- Tests/LayoutTests/UIKit/UILayoutSupportTests.swift | 2 +- Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift | 2 +- Tests/LayoutTests/UIKit/UIView+FramesTests.swift | 2 +- Tests/LayoutTests/UIKit/UIView+LayoutTests.swift | 2 +- Tests/LayoutTests/UIKit/UIView-AutoresizingMaskTests.swift | 2 +- Tests/LayoutTests/UIKit/UIViewControllerTests.swift | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Tests/LayoutTests/Attributes/CanonicalEdgeTests.swift b/Tests/LayoutTests/Attributes/CanonicalEdgeTests.swift index 78fc79da..9b39d426 100644 --- a/Tests/LayoutTests/Attributes/CanonicalEdgeTests.swift +++ b/Tests/LayoutTests/Attributes/CanonicalEdgeTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/Attributes/DirectionalEdgeTests.swift b/Tests/LayoutTests/Attributes/DirectionalEdgeTests.swift index 59bf216f..f34fe1bc 100644 --- a/Tests/LayoutTests/Attributes/DirectionalEdgeTests.swift +++ b/Tests/LayoutTests/Attributes/DirectionalEdgeTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift b/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift index 533f6254..d248c137 100644 --- a/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift +++ b/Tests/LayoutTests/Builders/ConstraintsBuilderTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/Builders/LayoutBuilderTests.swift b/Tests/LayoutTests/Builders/LayoutBuilderTests.swift index 4a00e592..88ebadd7 100644 --- a/Tests/LayoutTests/Builders/LayoutBuilderTests.swift +++ b/Tests/LayoutTests/Builders/LayoutBuilderTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift b/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift index c943b526..6c0d6d79 100644 --- a/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift +++ b/Tests/LayoutTests/LayoutItem/LayoutItems/UIView+LayoutItemTests.swift @@ -8,7 +8,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/LayoutItemTests.swift b/Tests/LayoutTests/LayoutItemTests.swift index f6775252..f3de7b36 100644 --- a/Tests/LayoutTests/LayoutItemTests.swift +++ b/Tests/LayoutTests/LayoutItemTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/Swift/ArrayTests.swift b/Tests/LayoutTests/Swift/ArrayTests.swift index 91ea7eea..cde5e85c 100644 --- a/Tests/LayoutTests/Swift/ArrayTests.swift +++ b/Tests/LayoutTests/Swift/ArrayTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift b/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift index a542bfab..3ff1439d 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutConstraintTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift b/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift index 18940c40..8d8a3e11 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutDimensionTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift b/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift index d49b48d8..f6d05813 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutXAxisAnchorTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift b/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift index ab0d94e1..02106eda 100644 --- a/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift +++ b/Tests/LayoutTests/UIKit/NSLayoutYAxisAnchorTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift b/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift index 46c3a763..f9b93ac6 100644 --- a/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift +++ b/Tests/LayoutTests/UIKit/UILayoutGuideTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/UILayoutPriorityTests.swift b/Tests/LayoutTests/UIKit/UILayoutPriorityTests.swift index 2bcfc9c3..496fcbbe 100644 --- a/Tests/LayoutTests/UIKit/UILayoutPriorityTests.swift +++ b/Tests/LayoutTests/UIKit/UILayoutPriorityTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/UILayoutSupportTests.swift b/Tests/LayoutTests/UIKit/UILayoutSupportTests.swift index da33e610..3046fe01 100644 --- a/Tests/LayoutTests/UIKit/UILayoutSupportTests.swift +++ b/Tests/LayoutTests/UIKit/UILayoutSupportTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift b/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift index e05622e5..0670e08a 100644 --- a/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+AutoLayoutTests.swift @@ -8,7 +8,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import UIKit import XCTest diff --git a/Tests/LayoutTests/UIKit/UIView+FramesTests.swift b/Tests/LayoutTests/UIKit/UIView+FramesTests.swift index c10e4205..4f162686 100644 --- a/Tests/LayoutTests/UIKit/UIView+FramesTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+FramesTests.swift @@ -8,7 +8,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift b/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift index 9c042de3..8347f83c 100644 --- a/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift +++ b/Tests/LayoutTests/UIKit/UIView+LayoutTests.swift @@ -8,7 +8,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import UIKit import XCTest diff --git a/Tests/LayoutTests/UIKit/UIView-AutoresizingMaskTests.swift b/Tests/LayoutTests/UIKit/UIView-AutoresizingMaskTests.swift index 655ac97a..a4aa0538 100644 --- a/Tests/LayoutTests/UIKit/UIView-AutoresizingMaskTests.swift +++ b/Tests/LayoutTests/UIKit/UIView-AutoresizingMaskTests.swift @@ -10,7 +10,7 @@ import Foundation -@testable import Layout +import Layout import Nimble import XCTest diff --git a/Tests/LayoutTests/UIKit/UIViewControllerTests.swift b/Tests/LayoutTests/UIKit/UIViewControllerTests.swift index cd8beb41..ea5b209a 100644 --- a/Tests/LayoutTests/UIKit/UIViewControllerTests.swift +++ b/Tests/LayoutTests/UIKit/UIViewControllerTests.swift @@ -7,7 +7,7 @@ // See https://github.com/Tinder/Layout/blob/main/LICENSE for license information. // -@testable import Layout +import Layout import Nimble import XCTest From 73a33329970f79fe3dafc7c0f339fd3dc3d49986 Mon Sep 17 00:00:00 2001 From: Christopher Fuller Date: Tue, 12 Dec 2023 16:13:37 -0800 Subject: [PATCH 3/4] Move default argument from insets to inset (#254) --- Sources/Layout/Layout.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Layout/Layout.swift b/Sources/Layout/Layout.swift index fc9cd6c4..070824a2 100644 --- a/Sources/Layout/Layout.swift +++ b/Sources/Layout/Layout.swift @@ -235,7 +235,7 @@ public final class Layout { // swiftlint:disable:this type_body_length public func constrain( _ view1: UIView, to view2: UIView, - insets: CanonicalInsets = .zero + insets: CanonicalInsets ) -> Layout { self .constrain(view1.left, to: view2.left, constant: insets.left) @@ -248,7 +248,7 @@ public final class Layout { // swiftlint:disable:this type_body_length public func constrain( _ view1: UIView, to view2: UIView, - inset: CGFloat + inset: CGFloat = 0 ) -> Layout { constrain(view1, to: view2, From b35c649c268a3ba44bd164e8dff33dd5e37ccd2e Mon Sep 17 00:00:00 2001 From: Christopher Fuller Date: Tue, 12 Dec 2023 16:13:57 -0800 Subject: [PATCH 4/4] Add require and prioritize methods to Layout (#255) --- Sources/Layout/Layout.swift | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/Layout/Layout.swift b/Sources/Layout/Layout.swift index 070824a2..443d729b 100644 --- a/Sources/Layout/Layout.swift +++ b/Sources/Layout/Layout.swift @@ -407,12 +407,6 @@ public final class Layout { // swiftlint:disable:this type_body_length return self } - @discardableResult - public func withPriority(_ priority: UILayoutPriority) -> Layout { - constraints.prioritize(priority) - return self - } - @discardableResult public func activate() -> Layout { constraints.activate() @@ -425,6 +419,19 @@ public final class Layout { // swiftlint:disable:this type_body_length return self } + public func require() -> Layout { + withPriority(.required) + } + + public func withPriority(_ priority: UILayoutPriority) -> Layout { + constraints.prioritize(priority) + return self + } + + public func prioritize(_ priority: UILayoutPriority) { + constraints.forEach { $0.prioritize(priority) } + } + public func update() { view?.setNeedsUpdateConstraints() view?.updateConstraintsIfNeeded()