Skip to content

Commit 3b5855a

Browse files
Use Swift 6
1 parent 05a7a69 commit 3b5855a

24 files changed

+65
-96
lines changed

.github/workflows/publishing.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ jobs:
214214
xcodebuild test \
215215
CODE_SIGNING_ALLOWED=no \
216216
-scheme Fyreplace \
217-
-destination platform=${{ matrix.platform }},OS=$(cat .ios-test-version) \
217+
-destination platform="${{ matrix.platform }} Simulator,OS=$(cat .ios-test-version),name=$(cat .ios-test-model)" \
218218
-only-testing FyreplaceTests
219219
220220
publish:

.ios-test-model

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
iPhone 16

.ios-test-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
17.5
1+
18.0

.xcode-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
15.4
1+
16

Fyreplace.xcodeproj/project.pbxproj

+4-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
4D9B3B382C334B3A00A8F7AD /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B372C334B3A00A8F7AD /* LoginScreen.swift */; };
4646
4D9B3B3A2C334B6300A8F7AD /* RegisterScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B392C334B6300A8F7AD /* RegisterScreen.swift */; };
4747
4D9B3B3D2C34B13E00A8F7AD /* LogoHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B3C2C34B13E00A8F7AD /* LogoHeader.swift */; };
48-
4D9B3B422C36E23A00A8F7AD /* Array+RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B412C36E23A00A8F7AD /* Array+RawRepresentable.swift */; };
4948
4D9B3B452C36F46F00A8F7AD /* NSTextContentType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B442C36F46F00A8F7AD /* NSTextContentType.swift */; };
5049
4D9B3B472C36F50300A8F7AD /* UITextContentType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B462C36F50300A8F7AD /* UITextContentType.swift */; };
5150
4D9DC5032C11BF2500BA0507 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9DC5022C11BF2500BA0507 /* Config.swift */; };
@@ -143,7 +142,6 @@
143142
4D9B3B372C334B3A00A8F7AD /* LoginScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
144143
4D9B3B392C334B6300A8F7AD /* RegisterScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterScreen.swift; sourceTree = "<group>"; };
145144
4D9B3B3C2C34B13E00A8F7AD /* LogoHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoHeader.swift; sourceTree = "<group>"; };
146-
4D9B3B412C36E23A00A8F7AD /* Array+RawRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+RawRepresentable.swift"; sourceTree = "<group>"; };
147145
4D9B3B442C36F46F00A8F7AD /* NSTextContentType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSTextContentType.swift; sourceTree = "<group>"; };
148146
4D9B3B462C36F50300A8F7AD /* UITextContentType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextContentType.swift; sourceTree = "<group>"; };
149147
4D9DC5022C11BF2500BA0507 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
@@ -152,6 +150,7 @@
152150
4DB10B4F2C4FEBFC00634BF6 /* HelpCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpCommands.swift; sourceTree = "<group>"; };
153151
4DB2E36C2C416611007F958D /* SubmitButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubmitButton.swift; sourceTree = "<group>"; };
154152
4DB2E36E2C418F5C007F958D /* DynamicForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicForm.swift; sourceTree = "<group>"; };
153+
4DBF0BD32C9DB2E500E797BF /* .ios-test-model */ = {isa = PBXFileReference; lastKnownFileType = text; path = ".ios-test-model"; sourceTree = "<group>"; };
155154
4DC5B1C92C6FA23000B75A07 /* LoginScreenProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreenProtocol.swift; sourceTree = "<group>"; };
156155
4DC5B1CC2C6FA28E00B75A07 /* RegisterScreenProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterScreenProtocol.swift; sourceTree = "<group>"; };
157156
4DC5B1CE2C6FA2BE00B75A07 /* MainViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewProtocol.swift; sourceTree = "<group>"; };
@@ -289,6 +288,7 @@
289288
4DF3737F2C99C23D0008AB04 /* .swift-format */,
290289
4D0DDC292C18A467006CD503 /* .xcode-version */,
291290
4D6641DB2C5B963500BE3D07 /* .ios-test-version */,
291+
4DBF0BD32C9DB2E500E797BF /* .ios-test-model */,
292292
4DCEF8652C452EBA00F53085 /* .env-example */,
293293
4DCEF8662C452ECC00F53085 /* .env */,
294294
4D54C9592BF266F9001DE071 /* Makefile */,
@@ -410,7 +410,6 @@
410410
isa = PBXGroup;
411411
children = (
412412
4DE785812C88B248000EC4E5 /* String.swift */,
413-
4D9B3B412C36E23A00A8F7AD /* Array+RawRepresentable.swift */,
414413
4D9B3B442C36F46F00A8F7AD /* NSTextContentType.swift */,
415414
4D9B3B462C36F50300A8F7AD /* UITextContentType.swift */,
416415
4DE785872C88F392000EC4E5 /* HTTPField.swift */,
@@ -641,7 +640,6 @@
641640
4D13AF7B2C4E8F4200845FDB /* EnvironmentPicker.swift in Sources */,
642641
4D30DA5F2C986B6C00499450 /* Avatar.swift in Sources */,
643642
4DC5B1CF2C6FA2BE00B75A07 /* MainViewProtocol.swift in Sources */,
644-
4D9B3B422C36E23A00A8F7AD /* Array+RawRepresentable.swift in Sources */,
645643
4D4D394A2C086DA2007196D2 /* PublishedScreen.swift in Sources */,
646644
4D5251EC2C1097A600018CD2 /* Destination.swift in Sources */,
647645
4D54C92E2BF2608A001DE071 /* MainView.swift in Sources */,
@@ -791,6 +789,7 @@
791789
ONLY_ACTIVE_ARCH = YES;
792790
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
793791
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
792+
SWIFT_VERSION = 6.0;
794793
};
795794
name = Debug;
796795
};
@@ -854,6 +853,7 @@
854853
MTL_ENABLE_DEBUG_INFO = NO;
855854
MTL_FAST_MATH = YES;
856855
SWIFT_COMPILATION_MODE = wholemodule;
856+
SWIFT_VERSION = 6.0;
857857
};
858858
name = Release;
859859
};
@@ -889,7 +889,6 @@
889889
SDKROOT = auto;
890890
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
891891
SWIFT_EMIT_LOC_STRINGS = YES;
892-
SWIFT_VERSION = 5.0;
893892
TARGETED_DEVICE_FAMILY = "1,2";
894893
};
895894
name = Debug;
@@ -926,7 +925,6 @@
926925
SDKROOT = auto;
927926
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
928927
SWIFT_EMIT_LOC_STRINGS = YES;
929-
SWIFT_VERSION = 5.0;
930928
TARGETED_DEVICE_FAMILY = "1,2";
931929
};
932930
name = Release;
@@ -942,7 +940,6 @@
942940
SDKROOT = auto;
943941
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
944942
SWIFT_EMIT_LOC_STRINGS = NO;
945-
SWIFT_VERSION = 5.0;
946943
TARGETED_DEVICE_FAMILY = "1,2";
947944
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Fyreplace.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Fyreplace";
948945
};
@@ -959,7 +956,6 @@
959956
SDKROOT = auto;
960957
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
961958
SWIFT_EMIT_LOC_STRINGS = NO;
962-
SWIFT_VERSION = 5.0;
963959
TARGETED_DEVICE_FAMILY = "1,2";
964960
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Fyreplace.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Fyreplace";
965961
};
@@ -975,7 +971,6 @@
975971
SDKROOT = auto;
976972
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
977973
SWIFT_EMIT_LOC_STRINGS = NO;
978-
SWIFT_VERSION = 5.0;
979974
TARGETED_DEVICE_FAMILY = "1,2";
980975
TEST_TARGET_NAME = Fyreplace;
981976
};
@@ -991,7 +986,6 @@
991986
SDKROOT = auto;
992987
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
993988
SWIFT_EMIT_LOC_STRINGS = NO;
994-
SWIFT_VERSION = 5.0;
995989
TARGETED_DEVICE_FAMILY = "1,2";
996990
TEST_TARGET_NAME = Fyreplace;
997991
};

Fyreplace/Config/Config.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import OpenAPIURLSession
22
import SwiftUI
33

44
struct Config {
5-
static var `default` = Config(from: Bundle.main)
5+
static let `default` = Config(from: Bundle.main)
66

77
let version: Version
88
let app: App
@@ -127,7 +127,7 @@ extension [String: Any] {
127127
}
128128

129129
private struct ConfigEnvironmentKey: EnvironmentKey {
130-
static var defaultValue = Config(from: Bundle.main)
130+
static let defaultValue = Config(from: Bundle.main)
131131
}
132132

133133
extension EnvironmentValues {

Fyreplace/Data/AuthenticationMiddleware.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct AuthenticationMiddleware: ClientMiddleware {
1111
next: @Sendable (HTTPRequest, HTTPBody?, URL) async throws -> (HTTPResponse, HTTPBody?)
1212
) async throws -> (HTTPResponse, HTTPBody?) {
1313
var request = request
14-
let token = KeychainCache.shared(for: "connection.token").value
14+
let token = await KeychainCache.shared(for: "connection.token").value
1515

1616
if !token.isEmpty {
1717
request.headerFields[.authorization] = "Bearer \(token)"

Fyreplace/Data/Keychain.swift

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ actor KeychainActor: GlobalActor {
5454
static let shared = KeychainActor()
5555
}
5656

57+
@MainActor
5758
@propertyWrapper
5859
struct KeychainStorage: DynamicProperty {
5960
@ObservedObject
@@ -81,6 +82,7 @@ struct KeychainStorage: DynamicProperty {
8182
}
8283
}
8384

85+
@MainActor
8486
class KeychainCache: ObservableObject {
8587
private static var instances: [String: KeychainCache] = [:]
8688

Fyreplace/Events/Event.swift

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import SwiftUI
22

3-
protocol Event {}
3+
@MainActor
4+
protocol Event: Sendable {}
45

6+
@MainActor
57
protocol UnfortunateEvent: Event {}
68

7-
struct ErrorEvent: UnfortunateEvent {
8-
let error: UnexpectedError
9+
struct ErrorEvent: UnfortunateEvent, LocalizedError {
10+
static let defaultDescription: String.LocalizationValue = "Error.Unknown"
911

10-
init(_ error: UnexpectedError) {
11-
self.error = error
12+
var description = defaultDescription
13+
14+
var errorDescription: String {
15+
.init(localized: description)
1216
}
1317
}
1418

Fyreplace/Extensions/Array+RawRepresentable.swift

-18
This file was deleted.

Fyreplace/Views/MainView.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct MainView: View, MainViewProtocol {
1111
var showFailure = false
1212

1313
@State
14-
var errors: [UnexpectedError] = []
14+
var errors: [ErrorEvent] = []
1515

1616
@State
1717
var failures: [FailureEvent] = []
@@ -55,7 +55,7 @@ struct MainView: View, MainViewProtocol {
5555
Text(failure.text)
5656
}
5757
)
58-
.onReceive(eventBus.events.compactMap { ($0 as? ErrorEvent)?.error }, perform: addError)
58+
.onReceive(eventBus.events.compactMap { ($0 as? ErrorEvent) }, perform: addError)
5959
.onReceive(eventBus.events.compactMap { ($0 as? FailureEvent) }, perform: addFailure)
6060
.onReceive(eventBus.events.filter { $0 is AuthorizationIssueEvent }) { _ in
6161
token = ""

Fyreplace/Views/MainViewProtocol.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
import Foundation
2+
3+
@MainActor
14
protocol MainViewProtocol: ViewProtocol {
25
var showError: Bool { get nonmutating set }
36
var showFailure: Bool { get nonmutating set }
4-
var errors: [UnexpectedError] { get nonmutating set }
7+
var errors: [ErrorEvent] { get nonmutating set }
58
var failures: [FailureEvent] { get nonmutating set }
69
}
710

811
@MainActor
912
extension MainViewProtocol {
10-
func addError(_ error: UnexpectedError) {
13+
func addError(_ error: ErrorEvent) {
1114
errors.append(error)
1215
tryShowSomething()
1316
}

Fyreplace/Views/Navigation/CompactNavigation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ struct CompactNavigation: View, NavigationProtocol {
77
@SceneStorage("CompactNavigation.selectedDestination")
88
private var selectedDestination = Destination.feed
99

10-
@SceneStorage("CompactNavigation.selectedChoices")
10+
@State
1111
private var selectedChoices = Destination.essentials
1212

1313
@AppStorage("account.isRegistering")

Fyreplace/Views/Navigation/Destination.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SwiftUI
22

3-
public enum Destination: String, Codable, Identifiable {
3+
enum Destination: String, Identifiable {
44
case feed
55
case notifications
66
case archive
@@ -10,7 +10,7 @@ public enum Destination: String, Codable, Identifiable {
1010
case login
1111
case register
1212

13-
public var id: String {
13+
var id: String {
1414
.init(reflecting: self)
1515
}
1616

Fyreplace/Views/Navigation/NavigationProtocol.swift

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22

3+
@MainActor
34
protocol NavigationProtocol {
45
var eventBus: EventBus { get }
56

Fyreplace/Views/Screens/LoginScreen.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,14 @@ struct LoginScreen: View, LoginScreenProtocol {
122122
}
123123
}
124124

125+
@available(macOS 14.0, *)
126+
@available(iOS 17.0, *)
125127
#Preview {
126-
NavigationStack {
127-
@Namespace
128-
var namespace
128+
@Previewable
129+
@Namespace
130+
var namespace
129131

132+
NavigationStack {
130133
LoginScreen(namespace: namespace)
131134
}
132135
.environmentObject(EventBus())

Fyreplace/Views/Screens/LoginScreenProtocol.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@MainActor
12
protocol LoginScreenProtocol: LoadingViewProtocol {
23
var api: APIProtocol { get }
34

@@ -52,7 +53,7 @@ extension LoginScreenProtocol {
5253
)
5354

5455
case .default:
55-
return .error(UnknownError())
56+
return .error()
5657
}
5758
}
5859

@@ -90,7 +91,7 @@ extension LoginScreenProtocol {
9091
)
9192

9293
case .default:
93-
return .error(UnknownError())
94+
return .error()
9495
}
9596
}
9697
}

Fyreplace/Views/Screens/RegisterScreen.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,14 @@ struct RegisterScreen: View, RegisterScreenProtocol {
161161
}
162162
}
163163

164+
@available(macOS 14.0, *)
165+
@available(iOS 17.0, *)
164166
#Preview {
165-
NavigationStack {
166-
@Namespace
167-
var namespace
167+
@Previewable
168+
@Namespace
169+
var namespace
168170

171+
NavigationStack {
169172
RegisterScreen(namespace: namespace)
170173
}
171174
.environmentObject(EventBus())

Fyreplace/Views/Screens/RegisterScreenProtocol.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@MainActor
12
protocol RegisterScreenProtocol: LoadingViewProtocol {
23
var api: APIProtocol { get }
34

@@ -84,7 +85,7 @@ extension RegisterScreenProtocol {
8485
}
8586

8687
case .default:
87-
return .error(UnknownError())
88+
return .error()
8889
}
8990
}
9091

@@ -124,7 +125,7 @@ extension RegisterScreenProtocol {
124125
)
125126

126127
case .default:
127-
return .error(UnknownError())
128+
return .error()
128129
}
129130
}
130131
}

Fyreplace/Views/Screens/SettingsScreenProtocol.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@MainActor
12
protocol SettingsScreenProtocol: ViewProtocol {
23
var api: APIProtocol { get }
34

@@ -23,7 +24,7 @@ extension SettingsScreenProtocol {
2324
return .authorizationIssue()
2425

2526
case .forbidden, .default:
26-
return .error(UnknownError())
27+
return .error()
2728
}
2829
}
2930
}

0 commit comments

Comments
 (0)