Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict concurrency and project maintenance #132

Merged
merged 9 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 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']
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice I've never seen a difference across iOS versions with Paralayout's test suite, so not too concerned about having more limited iOS version coverage. I think the advantage of having 2x and 3x scales here outweighs the version matrix.

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 //...
run: bazel test //... --xcode_version=15.4.0
6 changes: 4 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ swift_library(
name = "Paralayout.lib",
srcs = glob(["Paralayout/**/*.swift"]),
module_name = "Paralayout",
copts = ["-strict-concurrency=complete"],
tags = ["manual"],
visibility = ["//visibility:public"],
deps = [],
Expand All @@ -22,6 +23,7 @@ swift_library(
testonly = True,
srcs = glob(["ParalayoutTests/**/*.swift"]),
module_name = "ParalayoutTests",
copts = ["-strict-concurrency=complete"],
tags = ["manual"],
deps = [":Paralayout.lib"],
)
Expand All @@ -34,15 +36,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"],
)
4 changes: 3 additions & 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 Expand Up @@ -418,6 +418,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
};
name = Debug;
};
Expand Down Expand Up @@ -472,6 +473,7 @@
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
VALIDATE_PRODUCT = YES;
};
name = Release;
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
17 changes: 10 additions & 7 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,7 +21,7 @@ import PackageDescription
let package = Package(
name: "Paralayout",
platforms: [
.iOS(.v12),
.iOS(.v13),
],
products: [
.library(
Expand All @@ -33,13 +33,16 @@ let package = Package(
.target(
name: "Paralayout",
dependencies: [],
path: "Paralayout"
path: "Paralayout",
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
]
),
.testTarget(
name: "ParalayoutTests",
dependencies: ["Paralayout"],
path: "ParalayoutTests"
),
name: "ParalayoutTests",
dependencies: ["Paralayout"],
path: "ParalayoutTests"
),
],
swiftLanguageVersions: [.v5]
)
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
Loading
Loading