Skip to content

Commit 17d8ace

Browse files
authored
FEATURE: Swift Strict Concurrency support (#170)
1 parent dca0aff commit 17d8ace

File tree

130 files changed

+501
-386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+501
-386
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
env:
20-
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
21-
BUILD_JOB_COUNT: 4
20+
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
2221

2322
jobs:
2423
build-test:
@@ -29,10 +28,10 @@ jobs:
2928
uses: actions/checkout@v4
3029

3130
- name: Build
32-
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
31+
run: swift build --build-tests -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete
3332

3433
- name: Test
35-
run: swift test --filter TMDbTests --enable-code-coverage
34+
run: swift test --filter TMDbTests --enable-code-coverage -Xswiftc -strict-concurrency=complete
3635

3736
- name: Prepare Code Coverage
3837
run: |
@@ -49,7 +48,7 @@ jobs:
4948
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5049

5150
- name: Build for Release
52-
run: swift build -c release --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
51+
run: swift build -c release -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete
5352

5453
build-and-test-platforms:
5554
name: Build and Test (${{ matrix.name }})
@@ -59,22 +58,22 @@ jobs:
5958
matrix:
6059
include:
6160
- name: iOS
62-
destination: platform=iOS Simulator,name=iPhone 15,OS=17.2
61+
destination: platform=iOS Simulator,name=iPhone 15,OS=17.4
6362
- name: watchOS
64-
destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2
63+
destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.4
6564
- name: tvOS
66-
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2
65+
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.4
6766
- name: visionOS
68-
destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.0
67+
destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.1
6968
steps:
7069
- name: Checkout
7170
uses: actions/checkout@v4
7271

7372
- name: Build
74-
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' -parallelizeTargets 2>&1 | xcbeautify
73+
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' | xcbeautify
7574

7675
- name: Test
77-
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' -parallel-testing-enabled YES 2>&1 | xcbeautify
76+
run: set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' | xcbeautify
7877

7978
build-test-linux:
8079
name: Build and Test (Linux)
@@ -85,10 +84,10 @@ jobs:
8584
uses: actions/checkout@v4
8685

8786
- name: Build
88-
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
87+
run: swift build --build-tests -Xswiftc -warnings-as-errors
8988

9089
- name: Test
91-
run: swift test --skip-build --parallel --filter TMDbTests
90+
run: swift test --skip-build --filter TMDbTests
9291

9392
- name: Build for Release
94-
run: swift build -c release --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors
93+
run: swift build -c release -Xswiftc -warnings-as-errors

.github/workflows/codeql.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ on:
99
- main
1010
schedule:
1111
# Every Sunday at 12am
12-
- cron: '0 0 * * 0'
12+
- cron: '0 0 * * 0'
1313
workflow_dispatch:
1414

1515
concurrency:
1616
group: "codeql-${{ github.head_ref || github.run_id }}"
1717
cancel-in-progress: true
1818

1919
env:
20-
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
21-
BUILD_JOB_COUNT: 4
20+
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
2221

2322
jobs:
2423
analyze:
@@ -40,7 +39,7 @@ jobs:
4039
config-file: ./.github/codeql/codeql-config.yml
4140

4241
- name: Build
43-
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }}
42+
run: swift build --build-tests
4443

4544
- name: Perform CodeQL Analysis
4645
uses: github/codeql-action/analyze@v3

.github/workflows/integration.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ on:
1212
- "**/*.swift"
1313
schedule:
1414
# Every Sunday at 12am
15-
- cron: '0 0 * * 0'
15+
- cron: '0 0 * * 0'
1616
workflow_dispatch:
1717

1818
concurrency:
1919
group: "integration-${{ github.head_ref || github.run_id }}"
2020
cancel-in-progress: true
2121

2222
env:
23-
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
24-
BUILD_JOB_COUNT: 4
23+
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer
2524

2625
jobs:
2726
integration-test:
@@ -32,7 +31,7 @@ jobs:
3231
uses: actions/checkout@v4
3332

3433
- name: Build
35-
run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }}
34+
run: swift build --build-tests
3635

3736
- name: Test
3837
run: swift test --skip-build --filter TMDbIntegrationTests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ xcuserdata/
88
*.xctestplan
99
docs/
1010
info.lcov
11+
default.profraw

Makefile

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ TARGET = TMDb
22
TEST_TARGET = TMDbTests
33
INTEGRATION_TEST_TARGET = TMDbIntegrationTests
44

5-
IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.2'
6-
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2'
7-
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2'
5+
IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.4'
6+
WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.4'
7+
TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.4'
88
VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=1.1'
9-
BUILD_JOB_COUNT = 4
109

1110
SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy
1211

@@ -32,19 +31,19 @@ lint-markdown:
3231

3332
.PHONY: build
3433
build:
35-
swift build --jobs 4 -Xswiftc -warnings-as-errors
34+
swift build -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete
3635

3736
.PHONY: build-linux
3837
build-linux:
39-
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors"
38+
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete"
4039

4140
.PHONY: build-release
4241
build-release:
43-
swift build -c release --jobs 4 -Xswiftc -warnings-as-errors
42+
swift build -c release -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete
4443

4544
.PHONY: build-linux-release
4645
build-linux-release:
47-
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors"
46+
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete"
4847

4948
.PHONY: build-docs
5049
build-docs:
@@ -66,37 +65,37 @@ generate-docs:
6665

6766
.PHONY: test
6867
test:
69-
swift build --build-tests --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors
70-
swift test --skip-build --parallel --filter $(TEST_TARGET)
68+
swift build --build-tests -Xswiftc -warnings-as-errors -Xswiftc -strict-concurrency=complete
69+
swift test --skip-build --filter $(TEST_TARGET) -Xswiftc -strict-concurrency=complete
7170

7271
.PHONY: test-ios
7372
test-ios:
74-
set -o pipefail && NSUnbufferedIO=YES xcodebuild clean build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify
75-
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
73+
set -o pipefail && NSUnbufferedIO=YES xcodebuild clean build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) | xcbeautify
74+
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) | xcbeautify
7675

7776
.PHONY: test-watchos
7877
test-watchos:
79-
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) -parallelizeTargets 2>&1 | xcbeautify
80-
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
78+
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) | xcbeautify
79+
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) | xcbeautify
8180

8281
.PHONY: test-tvos
8382
test-tvos:
84-
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify
85-
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
83+
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) | xcbeautify
84+
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) | xcbeautify
8685

8786
.PHONY: test-visionos
8887
test-visionos:
89-
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify
90-
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify
88+
set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) | xcbeautify
89+
set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) | xcbeautify
9190

9291
.PHONY: test-linux
9392
test-linux:
94-
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)"
93+
docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)"
9594

9695
.PHONY: integration-test
9796
integration-test: .check-env-vars
98-
swift build --build-tests --jobs $(BUILD_JOB_COUNT)
99-
swift test --skip-build --filter $(INTEGRATION_TEST_TARGET)
97+
swift build --build-tests -Xswiftc -strict-concurrency=complete
98+
swift test --skip-build --filter $(INTEGRATION_TEST_TARGET) -Xswiftc -strict-concurrency=complete
10099

101100
.PHONY: ci
102101
ci: .check-env-vars lint lint-markdown test test-ios test-watchos test-tvos test-visionos test-linux integration-test build-release build-docs

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ Add the TMDb package as a dependency to your `Package.swift` file, and add it
2828
as a dependency to your target.
2929

3030
```swift
31-
// swift-tools-version:5.9
31+
// swift-tools-version:5.10
3232

3333
import PackageDescription
3434

3535
let package = Package(
3636
name: "MyProject",
3737

3838
dependencies: [
39-
.package(url: "https://github.com/adamayoung/TMDb.git", from: "11.0.0")
39+
.package(url: "https://github.com/adamayoung/TMDb.git", from: "12.0.0")
4040
],
4141

4242
targets: [

Sources/TMDb/Models/APIConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Foundation
2626
/// the actual API responses as light as possible. It is recommended you cache this data within your application and
2727
/// check for updates every few days.
2828
///
29-
public struct APIConfiguration: Codable, Equatable, Hashable {
29+
public struct APIConfiguration: Codable, Equatable, Hashable, Sendable {
3030

3131
///
3232
/// Images configuration.

Sources/TMDb/Models/AccountAvatar.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a TMDb user's avatar.
2424
///
25-
public struct AccountAvatar: Codable, Equatable, Hashable {
25+
public struct AccountAvatar: Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Gravatar avatar.
@@ -56,7 +56,7 @@ public extension AccountAvatar {
5656
///
5757
/// A model representing a TMDb user's Gravatar avatar.
5858
///
59-
struct Gravatar: Codable, Equatable, Hashable {
59+
struct Gravatar: Codable, Equatable, Hashable, Sendable {
6060

6161
///
6262
/// Gravatar hash.
@@ -80,7 +80,7 @@ public extension AccountAvatar {
8080
///
8181
/// A model representing a TMDb user's TMDb avatar.
8282
///
83-
struct TMDb: Codable, Equatable, Hashable {
83+
struct TMDb: Codable, Equatable, Hashable, Sendable {
8484

8585
///
8686
/// Path of the avatar image.

Sources/TMDb/Models/AccountDetails.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a TMDb user's account details.
2424
///
25-
public struct AccountDetails: Identifiable, Codable, Equatable, Hashable {
25+
public struct AccountDetails: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// User identifier.

Sources/TMDb/Models/CastMember.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a cast member.
2424
///
25-
public struct CastMember: Identifiable, Codable, Equatable, Hashable {
25+
public struct CastMember: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Cast member's identifier.

Sources/TMDb/Models/Certification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing an officially supported certification.
2424
///
25-
public struct Certification: Identifiable, Codable, Equatable, Hashable {
25+
public struct Certification: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Certification's identifier (same as ``code``).

Sources/TMDb/Models/Certifications.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import Foundation
2121

22-
struct Certifications: Codable, Equatable, Hashable {
22+
struct Certifications: Codable, Equatable, Hashable, Sendable {
2323

2424
let certifications: [String: [Certification]]
2525

Sources/TMDb/Models/Company.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a production company.
2424
///
25-
public struct Company: Identifiable, Codable, Equatable, Hashable {
25+
public struct Company: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Company identifier.
@@ -106,7 +106,7 @@ public extension Company {
106106
///
107107
/// A model representing a parent company.
108108
///
109-
struct Parent: Identifiable, Codable, Equatable, Hashable {
109+
struct Parent: Identifiable, Codable, Equatable, Hashable, Sendable {
110110

111111
///
112112
/// Company identifier.

Sources/TMDb/Models/Country.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a country.
2424
///
25-
public struct Country: Identifiable, Codable, Equatable, Hashable {
25+
public struct Country: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Country's identifier (same as `countryCode`).

Sources/TMDb/Models/Credential.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a user's TMDb username and password.
2424
///
25-
public struct Credential {
25+
public struct Credential: Sendable {
2626

2727
///
2828
/// User's username.

Sources/TMDb/Models/CrewMember.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a crew member..
2424
///
25-
public struct CrewMember: Identifiable, Codable, Equatable, Hashable {
25+
public struct CrewMember: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Crew member's identifier.

Sources/TMDb/Models/Department.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a department and jobs.
2424
///
25-
public struct Department: Identifiable, Codable, Equatable, Hashable {
25+
public struct Department: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Departments's identifier (same as `name`).

Sources/TMDb/Models/ExternalLink.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Foundation
2424
///
2525
/// e.g. to a Movie's IMDb page.
2626
///
27-
public protocol ExternalLink: Equatable, Hashable {
27+
public protocol ExternalLink: Equatable, Hashable, Sendable {
2828

2929
///
3030
/// The external site's item identifier.

Sources/TMDb/Models/Gender.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing the gender of a person.
2424
///
25-
public enum Gender: Int, Codable, Equatable, Hashable {
25+
public enum Gender: Int, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// An unknown gender.

Sources/TMDb/Models/Genre.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Foundation
2222
///
2323
/// A model representing a genre.
2424
///
25-
public struct Genre: Identifiable, Codable, Equatable, Hashable {
25+
public struct Genre: Identifiable, Codable, Equatable, Hashable, Sendable {
2626

2727
///
2828
/// Genre Identifier.

0 commit comments

Comments
 (0)