Skip to content

Commit

Permalink
Strict concurrency and project maintenance
Browse files Browse the repository at this point in the history
* Support strict conncurrency
* Update CI builds to run on macOS 14
* Update snapshot tests to run on iOS 17 and iPadOS 17
* Bump minimum deployment target to iOS 13
  • Loading branch information
NickEntin committed Aug 28, 2024
1 parent 420dc31 commit a5799f7
Show file tree
Hide file tree
Showing 193 changed files with 110 additions and 79 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ on:
jobs:
xcode-build:
name: Xcode Build
runs-on: macOS-11
runs-on: macOS-14
strategy:
matrix:
platform: ['iOS_14', 'iOS_13']
platform: ['iOS_17', 'iPadOS_17']
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_13.2.1.app/Contents/Developer
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platform }}
run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer
- name: Bundle Install
run: bundle install
- name: Pod Install
Expand All @@ -35,37 +33,37 @@ jobs:
path: .build/derivedData/**/Logs/Test/*.xcresult
pod-lint:
name: Lint Pod
runs-on: macOS-12
runs-on: macOS-14
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Bundle Install
run: bundle install
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_14.1.app/Contents/Developer
run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer
- name: Lint Podspec
run: bundle exec pod lib lint --verbose --fail-fast
spm:
name: SPM Build
runs-on: macOS-12
runs-on: macOS-14
strategy:
matrix:
platform: ['iOS_16', 'iOS_15']
platform: ['iOS_17']
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_14.1.app/Contents/Developer
- name: Prepare Simulator Runtimes
run: Scripts/github/prepare-simulators.sh ${{ matrix.platform }}
run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer
- name: Build
run: Scripts/build.swift spm ${{ matrix.platform }} `which xcpretty`
bazel:
name: Bazel
runs-on: macOS-12
runs-on: macOS-14
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Select Xcode Version
run: sudo xcode-select --switch /Applications/Xcode_15.4.app/Contents/Developer
- name: Build and Test
run: bazel test //...
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ ios_framework(
"ipad",
],
infoplists = ["Paralayout/Info.plist"],
minimum_os_version = "12.0",
minimum_os_version = "13.0",
visibility = ["//visibility:public"],
deps = [":Paralayout.lib"],
)

ios_unit_test(
name = "ParalayoutTests",
bundle_name = "ParalayoutTests",
minimum_os_version = "12.0",
minimum_os_version = "13.0",
runner = "@rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
deps = [":ParalayoutTests.lib"],
)
2 changes: 1 addition & 1 deletion Example/ParalayoutDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down
8 changes: 4 additions & 4 deletions Example/ParalayoutSnapshotTests/SnapshotTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class SnapshotTestCase: XCTestCase {

private static let testedDevices = [

// iPhone 12 Pro (14.4)
TestDeviceConfig(systemVersion: "14.4", screenSize: CGSize(width: 390, height: 844), screenScale: 3),
// iPhone 15 Pro - iOS 17.5
TestDeviceConfig(systemVersion: "17.5", screenSize: CGSize(width: 393, height: 852), screenScale: 3),

// iPhone 11 Pro (13.7)
TestDeviceConfig(systemVersion: "13.7", screenSize: CGSize(width: 375, height: 812), screenScale: 3),
// iPad (10th Generation) - iPadOS 17.5
TestDeviceConfig(systemVersion: "17.5", screenSize: CGSize(width: 820, height: 1180), screenScale: 2),

]

Expand Down
10 changes: 10 additions & 0 deletions Example/ParalayoutSnapshotTests/ViewAlignmentSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import SnapshotTesting

final class ViewAlignmentSnapshotTests: SnapshotTestCase {

@MainActor
func testSiblingAlignment() {
let containerView = UIView(frame: .init(x: 0, y: 0, width: 200, height: 200))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -80,6 +81,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
verifySnapshot(receiverPosition: .center, targetPosition: .topRight, verticalOffset: -15)
}

@MainActor
func testLayoutDirection() {
let containerView = UIView(frame: .init(x: 0, y: 0, width: 100, height: 100))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -140,6 +142,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: []))
}

@MainActor
func testTransformHasNoEffect() {
let containerView = UIView(frame: .init(x: 0, y: 0, width: 100, height: 100))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -185,6 +188,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
verifySnapshot(receiverTransform: .identity, targetTransform: .init(scaleX: 2, y: 3))
}

@MainActor
func testNonZeroBoundsOrigin() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -213,6 +217,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: []))
}

@MainActor
func testAlignmentWithLayoutMargins() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -246,6 +251,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: ["bothLayoutMargins"]))
}

@MainActor
func testAlignmentUsingCapInsets() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 100))
containerView.backgroundColor = .white
Expand All @@ -269,6 +275,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: []))
}

@MainActor
func testAlignmentUsingFirstLine() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 100))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -299,6 +306,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: []))
}

@MainActor
func testAlignmentUsingFirstLineCapInsets() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 250, height: 100))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -329,6 +337,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: []))
}

@MainActor
func testAlignmentWithRect() {
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
containerView.backgroundColor = .white
Expand Down Expand Up @@ -365,6 +374,7 @@ final class ViewAlignmentSnapshotTests: SnapshotTestCase {
assertSnapshot(matching: containerView, as: .image, named: nameForSnapshot(with: []))
}

@MainActor
func testAlignmentWithFrame() {
let targetTransform = CGAffineTransform(translationX: -20, y: 10)
let receiverTransform = CGAffineTransform(scaleX: 0.8, y: 0.8)
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Paralayout (1.0.0)
- Paralayout/Tests (1.0.0)
- Paralayout (1.1.0)
- Paralayout/Tests (1.1.0)
- SnapshotTesting (1.8.2)

DEPENDENCIES:
Expand All @@ -17,9 +17,9 @@ EXTERNAL SOURCES:
:path: "../Paralayout.podspec"

SPEC CHECKSUMS:
Paralayout: 63a087763d2c7a1b9c55843064e889aa27bdb56a
Paralayout: 148233f7ff311384bcb209bf0b1b8a1578ad1d34
SnapshotTesting: 38947050d13960d57a4a9c166fcf51bca7d56970

PODFILE CHECKSUM: f0cdc6633e8d65e479af433fa427d7c0ce7c72b1

COCOAPODS: 1.11.3
COCOAPODS: 1.14.3
11 changes: 7 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0.1
// swift-tools-version:5.9

//
// Copyright 2020 Square Inc.
Expand All @@ -21,19 +21,22 @@ import PackageDescription
let package = Package(
name: "Paralayout",
platforms: [
.iOS(.v12),
.iOS(.v13),
],
products: [
.library(
name: "Paralayout",
targets: ["Paralayout"]
targets: ["Paralayout"]
),
],
targets: [
.target(
name: "Paralayout",
dependencies: [],
path: "Paralayout"
path: "Paralayout",
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
),
.testTarget(
name: "ParalayoutTests",
Expand Down
6 changes: 3 additions & 3 deletions Paralayout.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|
s.name = 'Paralayout'
s.version = '1.0.0'
s.version = '1.1.0'
s.license = 'Apache License, Version 2.0'
s.summary = 'Paralayout is a simple set of assistive UI layout utilities. Size and position your UI with pixel-perfect precision. Design will love you!'
s.homepage = 'https://github.com/square/Paralayout'
s.authors = 'Square'
s.source = { :git => 'https://github.com/square/Paralayout.git', :tag => s.version }
s.source_files = 'Paralayout/*.{swift}'
s.ios.deployment_target = '12.0'
s.swift_version = '5.0'
s.ios.deployment_target = '13.0'
s.swift_version = '5.9'

s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'ParalayoutTests/*{.swift}'
Expand Down
2 changes: 2 additions & 0 deletions Paralayout/Alignable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import UIKit

/// Describes an object that can participate in alignment. In practice, this represents a view.
@MainActor
public protocol Alignable {

var alignmentContext: AlignmentContext { get }

}

@MainActor
public struct AlignmentContext {

// MARK: - Life Cycle
Expand Down
2 changes: 1 addition & 1 deletion Paralayout/Angle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import CoreGraphics

public struct Angle: Comparable {
public struct Angle: Comparable, Sendable {

// MARK: - Public Static Properties

Expand Down
13 changes: 12 additions & 1 deletion Paralayout/AspectRatio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import UIKit

/// A value type representing the ratio between a width and a height.
public struct AspectRatio: Comparable, CustomDebugStringConvertible {
public struct AspectRatio: Comparable, CustomDebugStringConvertible, Sendable {

// MARK: - Public Static Properties

Expand Down Expand Up @@ -105,6 +105,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
///
/// - parameter width: The desired width.
/// - parameter scaleFactor: The view/window/screen to use for pixel rounding.
@MainActor
public func height(forWidth width: CGFloat, in scaleFactor: ScaleFactorProviding) -> CGFloat {
return (ratioHeight * width / ratioWidth).roundedToPixel(in: scaleFactor)
}
Expand All @@ -113,6 +114,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
///
/// - parameter height: The desired height.
/// - parameter scaleFactor: The view/window/screen to use for pixel rounding.
@MainActor
public func width(forHeight height: CGFloat, in scaleFactor: ScaleFactorProviding) -> CGFloat {
return (ratioWidth * height / ratioHeight).roundedToPixel(in: scaleFactor)
}
Expand All @@ -122,6 +124,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
///
/// - parameter width: The desired width.
/// - parameter scaleFactor: The view/window/screen to use for pixel rounding.
@MainActor
public func size(forWidth width: CGFloat, in scaleFactor: ScaleFactorProviding) -> CGSize {
return CGSize(
width: width,
Expand All @@ -134,6 +137,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
///
/// - parameter height: The desired height.
/// - parameter scaleFactor: The view/window/screen to use for pixel rounding.
@MainActor
public func size(forHeight height: CGFloat, in scaleFactor: ScaleFactorProviding) -> CGSize {
return CGSize(
width: width(forHeight: height, in: scaleFactor),
Expand All @@ -147,6 +151,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
/// - parameter size: The bounding size.
/// - parameter scaleFactor: The view/window/screen to use for pixel alignment.
/// - returns: A size with the receiver's aspect ratio, no larger than the bounding size.
@MainActor
public func size(toFit size: CGSize, in scaleFactor: ScaleFactorProviding) -> CGSize {
if size.aspectRatio <= self {
// Match width, narrow the height.
Expand All @@ -169,6 +174,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
/// - parameter scaleFactor: The view/window/screen to use for pixel alignment.
/// - parameter layoutDirection: The effective layout direction of the view in which the `rect` is defined.
/// - returns: A rect with the receiver's aspect ratio, strictly within the bounding rect.
@MainActor
public func rect(
toFit rect: CGRect,
at position: Position,
Expand All @@ -193,6 +199,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
/// - parameter context: The view/window/screen that provides the scale factor and effective layout direction in
/// which the rect should be positioned.
/// - returns: A rect with the receiver's aspect ratio, strictly within the bounding rect.
@MainActor
public func rect(
toFit rect: CGRect,
at position: Position,
Expand All @@ -212,6 +219,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
/// - parameter size: The bounding size.
/// - parameter scaleFactor: The view/window/screen to use for pixel alignment.
/// - returns: A size with the receiver's aspect ratio, at least as large as the bounding size.
@MainActor
public func size(toFill size: CGSize, in scaleFactor: ScaleFactorProviding) -> CGSize {
if size.aspectRatio <= self {
// Match height, expand the width.
Expand All @@ -234,6 +242,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
/// - parameter scaleFactor: The view/window/screen to use for pixel alignment.
/// - parameter layoutDirection: The effective layout direction of the view in which the `rect` is defined.
/// - returns: A rect with the receiver's aspect ratio, strictly containing the bounding rect.
@MainActor
public func rect(
toFill rect: CGRect,
at position: Position,
Expand All @@ -257,6 +266,7 @@ public struct AspectRatio: Comparable, CustomDebugStringConvertible {
/// - parameter context: The view/window/screen that provides the scale factor and effective layout direction in
/// which the rect should be positioned.
/// - returns: A rect with the receiver's aspect ratio, strictly containing the bounding rect.
@MainActor
public func rect(
toFill rect: CGRect,
at position: Position,
Expand Down Expand Up @@ -294,6 +304,7 @@ extension CGRect {

// MARK: - Life Cycle

@MainActor
fileprivate init(
size newSize: CGSize,
at position: Position,
Expand Down
2 changes: 1 addition & 1 deletion Paralayout/Interpolation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public enum Clamp {

// MARK: -

public struct Interpolation: Comparable {
public struct Interpolation: Comparable, Sendable {

// MARK: - Public Types

Expand Down
1 change: 1 addition & 0 deletions Paralayout/LayoutDirection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import UIKit

/// Defines an object that vends its current user interface layout direction.
@MainActor
public protocol LayoutDirectionProviding {

var effectiveUserInterfaceLayoutDirection: UIUserInterfaceLayoutDirection { get }
Expand Down
Loading

0 comments on commit a5799f7

Please sign in to comment.