Skip to content

Commit 749bbfb

Browse files
Apply standard Swift package configuration (#386)
* Apply standard Swift package configuration * Use iPhone 17 * Remove extraneous comma
1 parent f2c4828 commit 749bbfb

23 files changed

+115
-66
lines changed

.github/workflows/docc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ on:
77
branches: [ main ]
88

99
env:
10-
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
10+
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
1111

1212
jobs:
1313
docc:
1414
name: DocC
1515
runs-on: macos-latest
16+
permissions:
17+
contents: read
1618
steps:
1719
- name: Checkout source
18-
uses: actions/checkout@v4
20+
uses: actions/checkout@v6
1921
- name: Build
2022
run: make docs open="no" DERIVED_DATA_PATH="$(mktemp -d)"

.github/workflows/pages.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
tags: ['[0-9]+.[0-9]+.[0-9]+']
66

77
env:
8-
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
8+
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
99

1010
permissions:
1111
contents: read
@@ -23,9 +23,11 @@ jobs:
2323
name: github-pages
2424
url: ${{ steps.deployment.outputs.page_url }}
2525
runs-on: macos-latest
26+
permissions:
27+
contents: read
2628
steps:
2729
- name: Checkout source
28-
uses: actions/checkout@v4
30+
uses: actions/checkout@v6
2931
- name: Configure pages
3032
uses: actions/configure-pages@v5
3133
- name: Build documentation

.github/workflows/swift.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@ on:
77
branches: [ main ]
88

99
env:
10-
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
10+
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
1111

1212
jobs:
1313
swift:
1414
name: Swift
1515
runs-on: macos-latest
16+
permissions:
17+
contents: read
1618
env:
17-
SIMULATOR: iPhone 15
19+
SIMULATOR: iPhone 17
1820
steps:
1921
- name: Checkout source
20-
uses: actions/checkout@v4
22+
uses: actions/checkout@v6
2123
- name: Download swiftlint binary
2224
run: swift package resolve
2325
- name: Lint
2426
run: >
25-
"$(find ".build/artifacts/swiftlint" -type f -name swiftlint -perm +111 -print -quit)"
27+
"$(find ".build/artifacts/swiftlint" -path "*macos*" -type f -name swiftlint -perm +111 -print -quit)"
2628
lint --strict --reporter github-actions-logging
2729
- name: Resolve package dependencies
2830
run: xcodebuild -resolvePackageDependencies

.swiftlint-rules.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ only_rules:
99
- accessibility_label_for_image
1010
- accessibility_trait_for_button
1111
- anonymous_argument_in_multiline_closure
12-
- anyobject_protocol
1312
- array_init
13+
- async_without_await
14+
- attribute_name_spacing
1415
# - attributes
1516
- balanced_xctest_lifecycle
1617
- blanket_disable_command
@@ -94,7 +95,6 @@ only_rules:
9495
- implicitly_unwrapped_optional
9596
- inclusive_language
9697
# - indentation_width
97-
- inert_defer
9898
- invalid_swiftlint_command
9999
- is_disjoint
100100
- joined_default_parameter
@@ -145,6 +145,7 @@ only_rules:
145145
- opening_brace
146146
- operator_usage_whitespace
147147
- operator_whitespace
148+
- optional_data_string_conversion
148149
- optional_enum_case_matching
149150
- orphaned_doc_comment
150151
- overridden_super_call
@@ -155,6 +156,7 @@ only_rules:
155156
- prefer_nimble
156157
- prefer_self_in_static_references
157158
- prefer_self_type_over_type_of_self
159+
- prefer_type_checking
158160
- prefer_zero_over_explicit_init
159161
# - prefixed_toplevel_constant
160162
- private_action
@@ -177,6 +179,7 @@ only_rules:
177179
- redundant_objc_attribute
178180
- redundant_optional_initialization
179181
- redundant_self_in_closure
182+
- redundant_sendable
180183
- redundant_set_access_control
181184
# - redundant_string_enum_value
182185
- redundant_type_annotation
@@ -224,7 +227,6 @@ only_rules:
224227
- unneeded_synthesized_initializer
225228
- unowned_variable_capture
226229
- untyped_error_in_catch
227-
- unused_capture_list
228230
- unused_closure_parameter
229231
- unused_control_flow_label
230232
- unused_enumerated

Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,6 @@ delete-snapshots:
4747
echo "Deleted $$snapshots"; \
4848
done
4949

50-
.PHONY: site
51-
site: target ?= Layout
52-
site: prefix ?= $(shell pwd)
53-
site: DOCC_PATH = $(shell xcrun --find docc)
54-
site: ARCHIVE_PATH = .build/documentation/archive
55-
site:
56-
@make docs open="no"
57-
"$(DOCC_PATH)" process-archive \
58-
transform-for-static-hosting \
59-
"$(ARCHIVE_PATH)/$(target).doccarchive" \
60-
--hosting-base-path "/$(target)" \
61-
--output-path "$(prefix)/_site"
62-
cp docs.html "$(prefix)/_site/index.html"
63-
cp docs.html "$(prefix)/_site/documentation/index.html"
64-
mkdir -p "$(prefix)/_site/cheatsheet"
65-
cp cheatsheet.html "$(prefix)/_site/cheatsheet/index.html"
66-
6750
.PHONY: docs
6851
docs: target ?= Layout
6952
docs: destination ?= generic/platform=iOS
@@ -83,3 +66,20 @@ docs:
8366
-name "$(target).doccarchive" \
8467
-exec cp -R {} "$(ARCHIVE_PATH)/" \;
8568
$(if $(filter $(open),OPEN),@open "$(ARCHIVE_PATH)/$(target).doccarchive",)
69+
70+
.PHONY: site
71+
site: target ?= Layout
72+
site: prefix ?= $(shell pwd)
73+
site: DOCC_PATH = $(shell xcrun --find docc)
74+
site: ARCHIVE_PATH = .build/documentation/archive
75+
site:
76+
@make docs open="no"
77+
"$(DOCC_PATH)" process-archive \
78+
transform-for-static-hosting \
79+
"$(ARCHIVE_PATH)/$(target).doccarchive" \
80+
--hosting-base-path "$(target)" \
81+
--output-path "$(prefix)/_site"
82+
cp docs.html "$(prefix)/_site/index.html"
83+
cp docs.html "$(prefix)/_site/documentation/index.html"
84+
mkdir -p "$(prefix)/_site/cheatsheet"
85+
cp cheatsheet.html "$(prefix)/_site/cheatsheet/index.html"

Package.resolved

Lines changed: 32 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
// swift-tools-version:5.8
1+
// swift-tools-version:5.10
22

3+
import Foundation
34
import PackageDescription
45

6+
let environment = ProcessInfo.processInfo.environment
7+
8+
let treatWarningsAsErrors = environment["CI"] == "true"
9+
let enableSwiftLintBuildToolPlugin = environment["CODEQL_DIST"] == nil
10+
511
let package = Package(
612
name: "Layout",
713
platforms: [
@@ -19,13 +25,13 @@ let package = Package(
1925
dependencies: [
2026
.package(
2127
url: "https://github.com/realm/SwiftLint.git",
22-
exact: "0.56.2"),
28+
exact: "0.59.1"),
2329
.package(
2430
url: "https://github.com/Quick/Nimble.git",
25-
exact: "13.4.0"),
31+
exact: "14.0.0"),
2632
.package(
2733
url: "https://github.com/pointfreeco/swift-snapshot-testing.git",
28-
exact: "1.17.4"),
34+
exact: "1.18.9"),
2935
],
3036
targets: [
3137
.target(
@@ -52,11 +58,21 @@ let package = Package(
5258

5359
package.targets.forEach { target in
5460

55-
target.swiftSettings = [
56-
.enableExperimentalFeature("StrictConcurrency"),
57-
]
61+
// TODO: Remove upon enabling Swift 6 language mode:
62+
target.swiftSettings = (target.swiftSettings ?? []) + [.enableExperimentalFeature("StrictConcurrency")]
5863

59-
target.plugins = [
60-
.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint"),
61-
]
64+
if treatWarningsAsErrors {
65+
target.swiftSettings = (target.swiftSettings ?? []) + [
66+
// TODO: Remove unsafe flag upon upgrading to Swift tools v6.2 and uncomment subsequent settings:
67+
.unsafeFlags(["-warnings-as-errors"]),
68+
// .treatAllWarnings(as: .error),
69+
// .treatWarning("DeprecatedDeclaration", as: .warning),
70+
]
71+
}
72+
73+
if enableSwiftLintBuildToolPlugin {
74+
target.plugins = (target.plugins ?? []) + [
75+
.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint"),
76+
]
77+
}
6278
}

Sources/Layout/Builders/ConstraintsBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public enum ConstraintsBuilder {
5656
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
5757
/// ) for more information.
5858
public static func buildBlock(_ components: Component...) -> Component {
59-
components.flatMap { $0 }
59+
components.flatMap(\.self)
6060
}
6161

6262
/// See result builder [documentation](
@@ -84,7 +84,7 @@ public enum ConstraintsBuilder {
8484
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
8585
/// ) for more information.
8686
public static func buildArray(_ components: [Component]) -> Component {
87-
components.flatMap { $0 }
87+
components.flatMap(\.self)
8888
}
8989

9090
/// See result builder [documentation](

Sources/Layout/Builders/LayoutBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public enum LayoutBuilder {
5454
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
5555
/// ) for more information.
5656
public static func buildBlock(_ components: Component...) -> Component {
57-
components.flatMap { $0 }
57+
components.flatMap(\.self)
5858
}
5959

6060
/// See result builder [documentation](
@@ -82,7 +82,7 @@ public enum LayoutBuilder {
8282
/// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/attributes/#resultBuilder
8383
/// ) for more information.
8484
public static func buildArray(_ components: [Component]) -> Component {
85-
components.flatMap { $0 }
85+
components.flatMap(\.self)
8686
}
8787

8888
/// See result builder [documentation](

0 commit comments

Comments
 (0)