Skip to content

Commit

Permalink
Update project for building in Xcode 16 (#50)
Browse files Browse the repository at this point in the history
## Summary

This change makes the project builds in Xcode 16 without issues.

## What was done

- [x] Update Tuist to v4.30.0.
- [x] Disable Swift's InternalImportsByDefault feature.
- [x] Update Swift Package dependencies.
- [x] Fix use of deprecated APIs.
- [x] Fix Swift warnings.
  • Loading branch information
darrarski authored Oct 18, 2024
2 parents 4ae9f18 + 1be4988 commit bf117e4
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .mise.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tools]
tuist = "4.21.2"
tuist = "4.30.0"
2 changes: 1 addition & 1 deletion Projects/App/AppFeature/Sources/AppSecrets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import AppSecrets
import Dependencies
import Foundation

extension AppSecrets: DependencyKey {
extension AppSecrets: Dependencies.DependencyKey {
public static let liveValue = AppSecrets.live
public static let testValue = AppSecrets()
public static let previewValue = AppSecrets()
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/AppShared/Sources/_Concurrency.swift
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// NB: This silences warnings about non-sendable KeyPaths
extension KeyPath: @unchecked Sendable {}
extension KeyPath: @unchecked @retroactive Sendable {}
8 changes: 3 additions & 5 deletions Projects/App/ContactFeature/Tests/ContactReducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,17 @@ final class ContactReducerTests: XCTestCase {
iconURL: nil,
target: .system
)
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])
let store = TestStore(initialState: ContactReducer.State()) {
ContactReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.linkButtonTapped(link)))
await didOpenURL.withValue {
expectNoDifference($0, [link.url])
}
expectNoDifference(didOpenURL.value, [link.url])
}
}
28 changes: 12 additions & 16 deletions Projects/App/FeedFeature/Tests/FeedReducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import XCTest
final class FeedReducerTests: XCTestCase {
@MainActor func testFetchStatuses() async {
let clock = TestClock()
let didFetch = ActorIsolated<[Mastodon.GetAccountStatuses.Request]>([])
let didFetch = LockIsolated<[Mastodon.GetAccountStatuses.Request]>([])
let statuses = [Status].preview
let store = TestStore(initialState: FeedReducer.State()) {
FeedReducer()
} withDependencies: {
$0.continuousClock = clock
$0.mastodon.getAccountStatuses.send = { request in
await didFetch.withValue { $0.append(request) }
didFetch.withValue { $0.append(request) }
return statuses
}
}
Expand All @@ -22,13 +22,11 @@ final class FeedReducerTests: XCTestCase {
$0.isLoading = true
}
await clock.advance(by: .seconds(0.5))
await didFetch.withValue {
expectNoDifference($0, [.init(
accountId: FeedReducer.mastodonAccountId,
limit: 40,
excludeReplies: true
)])
}
expectNoDifference(didFetch.value, [.init(
accountId: FeedReducer.mastodonAccountId,
limit: 40,
excludeReplies: true
)])
await store.receive(\.fetchStatusesResult.success) {
$0.isLoading = false
$0.statuses = .init(
Expand Down Expand Up @@ -94,21 +92,19 @@ final class FeedReducerTests: XCTestCase {
}

@MainActor func testViewSeeMoreButtonTapped() async {
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])
let store = TestStore(initialState: FeedReducer.State()) {
FeedReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.seeMoreButtonTapped))
await didOpenURL.withValue {
expectNoDifference($0, [
FeedReducer.mastodonAccountURL
])
}
expectNoDifference(didOpenURL.value, [
FeedReducer.mastodonAccountURL
])
}
}
56 changes: 21 additions & 35 deletions Projects/App/FeedFeature/Tests/StatusReducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,59 @@ final class StatusReducerTests: XCTestCase {
let status = [Status].preview.first { $0.card != nil }!
let card = status.card!
let cardURL = URL(string: card.url)!
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])

let store = TestStore(initialState: StatusReducer.State(
status: status
)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.previewCardTapped))
await didOpenURL.withValue {
expectNoDifference($0, [cardURL])
}
expectNoDifference(didOpenURL.value, [cardURL])
}

@MainActor func testViewPreviewCardTappedOnRebloggedStatus() async {
let status = [Status].preview.first { $0.reblog?.card != nil }!
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])

let store = TestStore(initialState: StatusReducer.State(
status: status
)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.previewCardTapped))
await didOpenURL.withValue {
expectNoDifference($0, [URL(string: status.reblog!.card!.url)!])
}
expectNoDifference(didOpenURL.value, [URL(string: status.reblog!.card!.url)!])
}

@MainActor func testViewLinkTapped() async {
let url = URL(string: "https://darrarski.pl")!
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])

let store = TestStore(initialState: StatusReducer.State(
status: [Status].preview.first!
)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.linkTapped(url)))
await didOpenURL.withValue {
expectNoDifference($0, [url])
}
expectNoDifference(didOpenURL.value, [url])
}

@MainActor func testViewAttachmentTapped_Invalid() async {
Expand All @@ -84,20 +78,18 @@ final class StatusReducerTests: XCTestCase {
let attachment = status.reblog!.mediaAttachments
.first { $0.type == .video }!
let attachmentURL = URL(string: attachment.url)!
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])
let store = TestStore(initialState: StatusReducer.State(status: status)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.attachmentTapped(attachment.id)))
await didOpenURL.withValue {
expectNoDifference($0, [attachmentURL])
}
expectNoDifference(didOpenURL.value, [attachmentURL])
}

@MainActor func testViewAttachmentTapped_Image() async {
Expand All @@ -118,20 +110,18 @@ final class StatusReducerTests: XCTestCase {
$0.quickLookItem = nil
}
#else
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])
let store = TestStore(initialState: StatusReducer.State(status: status)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.attachmentTapped(attachment.id)))
await didOpenURL.withValue {
expectNoDifference($0, [attachmentURL])
}
expectNoDifference(didOpenURL.value, [attachmentURL])
#endif
}

Expand All @@ -153,41 +143,37 @@ final class StatusReducerTests: XCTestCase {
@MainActor func testViewHeaderTapped() async {
let status = [Status].preview.first { $0.reblog == nil }!
let statusURL = URL(string: status.url!)!
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])

let store = TestStore(initialState: StatusReducer.State(status: status)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.headerTapped))
await didOpenURL.withValue {
expectNoDifference($0, [statusURL])
}
expectNoDifference(didOpenURL.value, [statusURL])
}

@MainActor func testViewReblogHeaderTapped() async {
let status = [Status].preview.first { $0.reblog != nil }!
let statusURL = URL(string: status.reblog!.url!)!
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])

let store = TestStore(initialState: StatusReducer.State(status: status)) {
StatusReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.headerTapped))
await didOpenURL.withValue {
expectNoDifference($0, [statusURL])
}
expectNoDifference(didOpenURL.value, [statusURL])
}

@MainActor func testStateDisplayStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import XCTest

final class GetAccountStatusesTests: XCTestCase {
func testRequest() async throws {
let urlRequests = ActorIsolated<[URLRequest]>([])
let urlRequests = LockIsolated<[URLRequest]>([])
let responseStub = GetAccountStatuses.Response.preview
let response = try await withDependencies {
$0.httpClient.dataForRequest = { urlRequest in
await urlRequests.withValue { $0.append(urlRequest) }
urlRequests.withValue { $0.append(urlRequest) }
return (
GetAccountStatuses.Response.previewJSON,
HTTPURLResponse.stub(200)
Expand All @@ -25,14 +25,12 @@ final class GetAccountStatusesTests: XCTestCase {
)
}

await urlRequests.withValue {
XCTAssertEqual($0.count, 1)
if let urlRequest = $0.first {
assertInlineSnapshot(of: urlRequest, as: .raw) {
XCTAssertEqual(urlRequests.value.count, 1)
if let urlRequest = urlRequests.first {
assertInlineSnapshot(of: urlRequest, as: .raw) {
"""
GET https://mastodon.social/api/v1/accounts/account%20id/statuses?exclude_replies=true&limit=1337
"""
}
}
}
expectNoDifference(response, responseStub)
Expand Down
1 change: 1 addition & 0 deletions Projects/App/ProjectsFeature/Sources/ProjectsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public struct ProjectsView: View {
}

@Sendable
nonisolated
static func verticalScrollPositionHueRotation(
content: EmptyVisualEffect,
geometryProxy: GeometryProxy
Expand Down
8 changes: 3 additions & 5 deletions Projects/App/ProjectsFeature/Tests/ProjectsReducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ final class ProjectsReducerTests: XCTestCase {
}

@MainActor func testViewProjectCardTapped() async {
let didOpenURL = ActorIsolated<[URL]>([])
let didOpenURL = LockIsolated<[URL]>([])
let projects = IdentifiedArray(uniqueElements: [Project].preview)
let project = projects.first { $0.url != nil }!
let store = TestStore(initialState: ProjectsReducer.State(
Expand All @@ -124,14 +124,12 @@ final class ProjectsReducerTests: XCTestCase {
ProjectsReducer()
} withDependencies: {
$0.openURL = .init { url in
await didOpenURL.withValue { $0.append(url) }
didOpenURL.withValue { $0.append(url) }
return true
}
}

await store.send(.view(.projectCardTapped(project.id)))
await didOpenURL.withValue {
expectNoDifference($0, [project.url!])
}
expectNoDifference(didOpenURL.value, [project.url!])
}
}
3 changes: 0 additions & 3 deletions Projects/App/app-secrets/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ for target in package.targets where target.type == .regular {
#if !hasFeature(DisableOutwardActorInference)
swiftSettings.append(.enableUpcomingFeature("DisableOutwardActorInference"))
#endif
#if !hasFeature(InternalImportsByDefault)
swiftSettings.append(.enableUpcomingFeature("InternalImportsByDefault"))
#endif
#if !hasFeature(IsolatedDefaultValues)
swiftSettings.append(.enableUpcomingFeature("IsolatedDefaultValues"))
#endif
Expand Down
Loading

0 comments on commit bf117e4

Please sign in to comment.