Skip to content

Commit e95a02e

Browse files
Apply standard Swift package configuration (#9)
* Apply standard Swift package configuration * Add macOS platform to package manifest * Set iOS platform as docs destination * Do not set SWIFT_TREAT_WARNINGS_AS_ERRORS * Use iPhone 15 in Swift workflow * Set iOS platform as analyze destination
1 parent 2f36ba1 commit e95a02e

15 files changed

+182
-351
lines changed

.bazelversion

-1
This file was deleted.

.github/workflows/bazel.yml

-20
This file was deleted.

.github/workflows/docc.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: DocC
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
11+
12+
jobs:
13+
docc:
14+
name: DocC
15+
runs-on: macos-latest
16+
steps:
17+
- name: Checkout source
18+
uses: actions/checkout@v4
19+
- name: Build
20+
run: make docs open="no" DERIVED_DATA_PATH="$(mktemp -d)"

.github/workflows/swift.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ on:
77
branches: [ main ]
88

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

1212
jobs:
1313
swift:
1414
name: Swift
15-
runs-on: macos-13
15+
runs-on: macos-latest
1616
env:
17-
SIMULATOR: iPhone 14
17+
SIMULATOR: iPhone 15
1818
steps:
1919
- name: Checkout source
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
- name: Download swiftlint binary
2222
run: swift package resolve
2323
- name: Lint
24-
run: |
25-
DIRECTORY_NAME=$(echo "${PWD##*/}" | tr '[:upper:]' '[:lower:]')
26-
"$(find ".build/artifacts/${DIRECTORY_NAME}" -type f -name swiftlint -perm +111 -print -quit)" \
24+
run: >
25+
"$(find ".build/artifacts/swiftlint" -type f -name swiftlint -perm +111 -print -quit)"
2726
lint --strict --reporter github-actions-logging
2827
- name: Resolve package dependencies
2928
run: xcodebuild -resolvePackageDependencies
@@ -33,7 +32,7 @@ jobs:
3332
build-for-testing
3433
-scheme "CollectionBuilders"
3534
-destination "name=$SIMULATOR,OS=latest"
36-
SWIFT_TREAT_WARNINGS_AS_ERRORS=YES
35+
-skipPackagePluginValidation
3736
- name: Test
3837
run: >
3938
xcodebuild

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@
88
# Xcode
99
*.xcworkspace/
1010
*.xcodeproj/
11-
12-
# Bazel
13-
bazel-*

.swiftlint-rules.yml

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ only_rules:
3333
- contains_over_filter_is_empty
3434
- contains_over_first_not_nil
3535
- contains_over_range_nil_comparison
36+
# - contrasted_opening_brace
3637
- control_statement
3738
- convenience_type
3839
- custom_rules
@@ -73,6 +74,7 @@ only_rules:
7374
- file_name
7475
- file_name_no_space
7576
- file_types_order
77+
- final_test_case
7678
- first_where
7779
- flatmap_over_map_reduce
7880
- for_where
@@ -124,11 +126,13 @@ only_rules:
124126
- multiple_closures_with_trailing_closure
125127
- nesting
126128
- nimble_operator
129+
# - no_empty_block
127130
- no_extension_access_modifier
128131
- no_fallthrough_only
129132
- no_grouping_extension
130133
# - no_magic_numbers
131134
- no_space_in_method_call
135+
- non_optional_string_data_conversion
132136
- non_overridable_class_declaration
133137
- notification_center_detachment
134138
- ns_number_init_as_function_reference
@@ -137,6 +141,7 @@ only_rules:
137141
- nsobject_prefer_isequal
138142
- number_separator
139143
# - object_literal
144+
# - one_declaration_per_file
140145
- opening_brace
141146
- operator_usage_whitespace
142147
- operator_whitespace
@@ -146,6 +151,7 @@ only_rules:
146151
- override_in_extension
147152
- pattern_matching_keywords
148153
- period_spacing
154+
- prefer_key_path
149155
- prefer_nimble
150156
- prefer_self_in_static_references
151157
- prefer_self_type_over_type_of_self
@@ -181,6 +187,7 @@ only_rules:
181187
# - return_value_from_void_function
182188
- self_binding
183189
- self_in_property_initialization
190+
# - shorthand_argument
184191
- shorthand_operator
185192
- shorthand_optional_binding
186193
- single_test_class
@@ -189,6 +196,7 @@ only_rules:
189196
- sorted_imports
190197
- statement_position
191198
- static_operator
199+
- static_over_final_class
192200
- strict_fileprivate
193201
- strong_iboutlet
194202
- superfluous_disable_command
@@ -221,6 +229,7 @@ only_rules:
221229
- unused_control_flow_label
222230
- unused_enumerated
223231
- unused_optional_binding
232+
- unused_parameter
224233
- unused_setter_value
225234
- valid_ibinspectable
226235
- vertical_parameter_alignment

.swiftlint.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
included:
2-
- Plugins
32
- Sources
43
- Tests
54

BUILD.bazel

-15
This file was deleted.

CONTRIBUTING.md

+17-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,21 @@
11
# Contributing to CollectionBuilders
22

3-
- [Dependencies](#dependencies)
4-
- [Open Package in Xcode](#open-package-in-xcode)
5-
- [Static Analysis](#static-analysis)
6-
- [Testing](#testing)
3+
- [Open Package](#open-package)
4+
- [Lint Package](#lint-package)
5+
- [Creating Releases](#creating-releases)
76

8-
## Dependencies
9-
10-
Follow the [Swift Package Resources installation instructions](https://github.com/TinderApp/Swift-Package-Resources) to install tooling dependencies.
11-
12-
## Open Package in Xcode
7+
## Open Package
138

149
> The file header comment template will also be installed.
1510
1611
```
1712
make open
1813
```
1914

20-
## Static Analysis
15+
## Lint Package
2116

2217
> SwiftLint violations are visible in Xcode as well.
2318
24-
Package dependencies must be resolved to download the SwiftLint binary.
25-
26-
```
27-
swift package resolve
28-
```
29-
3019
To run SwiftLint from the command line:
3120

3221
```
@@ -39,8 +28,16 @@ To run analysis rules:
3928
make analyze
4029
```
4130

42-
To enable new rules whenever SwiftLint is upgraded to a new version:
31+
## Creating Releases
4332

44-
```
45-
make rules
46-
```
33+
Releases are made [on the GitHub website](https://github.com/Tinder/CollectionBuilders/releases/new).
34+
35+
In all of the following steps, `X.X.X` is a placeholder to be substituted with the actual semantic version for the release.
36+
37+
- Enter a semantic version as the new tag (__WITHOUT__ `v` prefix)
38+
- Set the `main` branch as the target (it should be the default)
39+
- Enter the release title formatted as `CollectionBuilders vX.X.X` (__WITH__ `v` prefix)
40+
- Click on `Generate release notes`
41+
- Leave `Set as a pre-release` unchecked
42+
- Leave `Set as the latest release` checked
43+
- Click `Publish release`

Makefile

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#
2-
# The SwiftLint recipes require the Swift Package Resources scripts to be installed.
3-
#
4-
# https://github.com/TinderApp/Swift-Package-Resources#installation
5-
#
6-
71
.PHONY: open
82
open: fix
93
open:
@@ -24,11 +18,12 @@ fix:
2418
.PHONY: lint
2519
lint: format ?= emoji
2620
lint:
27-
@swiftlint lint --strict --progress --reporter "$(format)"
21+
@swift package plugin \
22+
swiftlint lint --strict --progress --reporter "$(format)"
2823

2924
.PHONY: analyze
3025
analyze: target ?= CollectionBuilders
31-
analyze: destination ?= generic/platform=macOS
26+
analyze: destination ?= generic/platform=iOS
3227
analyze: format ?= emoji
3328
analyze:
3429
@DERIVED_DATA="$$(mktemp -d)"; \
@@ -38,10 +33,28 @@ analyze:
3833
-destination "$(destination)" \
3934
-derivedDataPath "$$DERIVED_DATA" \
4035
-configuration "Debug" \
36+
-skipPackagePluginValidation \
4137
CODE_SIGNING_ALLOWED="NO" \
4238
> "$$XCODEBUILD_LOG"; \
43-
swiftlint analyze --strict --progress --reporter "$(format)" --compiler-log-path "$$XCODEBUILD_LOG"
39+
swift package plugin \
40+
swiftlint analyze --strict --progress --reporter "$(format)" --compiler-log-path "$$XCODEBUILD_LOG"
4441

45-
.PHONY: rules
46-
rules:
47-
@swiftlint rules | lint-rules
42+
.PHONY: docs
43+
docs: target ?= CollectionBuilders
44+
docs: destination ?= generic/platform=iOS
45+
docs: open ?= OPEN
46+
docs: DERIVED_DATA_PATH = .build/documentation/data
47+
docs: ARCHIVE_PATH = .build/documentation/archive
48+
docs:
49+
@mkdir -p "$(DERIVED_DATA_PATH)" "$(ARCHIVE_PATH)"
50+
xcodebuild docbuild \
51+
-scheme "$(target)" \
52+
-destination "$(destination)" \
53+
-derivedDataPath "$(DERIVED_DATA_PATH)" \
54+
-skipPackagePluginValidation \
55+
OTHER_DOCC_FLAGS="--warnings-as-errors"
56+
@find "$(DERIVED_DATA_PATH)" \
57+
-type d \
58+
-name "$(target).doccarchive" \
59+
-exec cp -R {} "$(ARCHIVE_PATH)/" \;
60+
$(if $(filter $(open),OPEN),@open "$(ARCHIVE_PATH)/$(target).doccarchive",)

Package.resolved

+83-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"pins" : [
3+
{
4+
"identity" : "collectionconcurrencykit",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/JohnSundell/CollectionConcurrencyKit.git",
7+
"state" : {
8+
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
9+
"version" : "0.2.0"
10+
}
11+
},
12+
{
13+
"identity" : "cryptoswift",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/krzyzanowskim/CryptoSwift.git",
16+
"state" : {
17+
"revision" : "729e01bc9b9dab466ac85f21fb9ee2bc1c61b258",
18+
"version" : "1.8.4"
19+
}
20+
},
321
{
422
"identity" : "cwlcatchexception",
523
"kind" : "remoteSourceControl",
@@ -23,8 +41,71 @@
2341
"kind" : "remoteSourceControl",
2442
"location" : "https://github.com/Quick/Nimble.git",
2543
"state" : {
26-
"revision" : "d616f15123bfb36db1b1075153f73cf40605b39d",
27-
"version" : "13.0.0"
44+
"revision" : "54b4e52183f16fe806014cbfd63718a84f8ba072",
45+
"version" : "13.4.0"
46+
}
47+
},
48+
{
49+
"identity" : "sourcekitten",
50+
"kind" : "remoteSourceControl",
51+
"location" : "https://github.com/jpsim/SourceKitten.git",
52+
"state" : {
53+
"revision" : "fd4df99170f5e9d7cf9aa8312aa8506e0e7a44e7",
54+
"version" : "0.35.0"
55+
}
56+
},
57+
{
58+
"identity" : "swift-argument-parser",
59+
"kind" : "remoteSourceControl",
60+
"location" : "https://github.com/apple/swift-argument-parser.git",
61+
"state" : {
62+
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
63+
"version" : "1.5.0"
64+
}
65+
},
66+
{
67+
"identity" : "swift-syntax",
68+
"kind" : "remoteSourceControl",
69+
"location" : "https://github.com/swiftlang/swift-syntax.git",
70+
"state" : {
71+
"revision" : "515f79b522918f83483068d99c68daeb5116342d",
72+
"version" : "600.0.0-prerelease-2024-08-14"
73+
}
74+
},
75+
{
76+
"identity" : "swiftlint",
77+
"kind" : "remoteSourceControl",
78+
"location" : "https://github.com/realm/SwiftLint.git",
79+
"state" : {
80+
"revision" : "a24488f26e60247d8fff7bbb03d51910af3dc91c",
81+
"version" : "0.56.2"
82+
}
83+
},
84+
{
85+
"identity" : "swiftytexttable",
86+
"kind" : "remoteSourceControl",
87+
"location" : "https://github.com/scottrhoyt/SwiftyTextTable.git",
88+
"state" : {
89+
"revision" : "c6df6cf533d120716bff38f8ff9885e1ce2a4ac3",
90+
"version" : "0.9.0"
91+
}
92+
},
93+
{
94+
"identity" : "swxmlhash",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/drmohundro/SWXMLHash.git",
97+
"state" : {
98+
"revision" : "a853604c9e9a83ad9954c7e3d2a565273982471f",
99+
"version" : "7.0.2"
100+
}
101+
},
102+
{
103+
"identity" : "yams",
104+
"kind" : "remoteSourceControl",
105+
"location" : "https://github.com/jpsim/Yams.git",
106+
"state" : {
107+
"revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",
108+
"version" : "5.1.3"
28109
}
29110
}
30111
],

0 commit comments

Comments
 (0)