Skip to content

Commit

Permalink
Use Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Sep 20, 2024
1 parent 05a7a69 commit 5158199
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publishing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
xcodebuild test \
CODE_SIGNING_ALLOWED=no \
-scheme Fyreplace \
-destination platform=${{ matrix.platform }},OS=$(cat .ios-test-version) \
-destination platform="${{ matrix.platform }},OS=$(cat .ios-test-version),name=$(cat .ios-test-model)" \
-only-testing FyreplaceTests
publish:
Expand Down
1 change: 1 addition & 0 deletions .ios-test-model
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
iPhone 16
2 changes: 1 addition & 1 deletion .ios-test-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.5
18.0
2 changes: 1 addition & 1 deletion .xcode-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.4
16
14 changes: 4 additions & 10 deletions Fyreplace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
4D9B3B382C334B3A00A8F7AD /* LoginScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B372C334B3A00A8F7AD /* LoginScreen.swift */; };
4D9B3B3A2C334B6300A8F7AD /* RegisterScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B392C334B6300A8F7AD /* RegisterScreen.swift */; };
4D9B3B3D2C34B13E00A8F7AD /* LogoHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B3C2C34B13E00A8F7AD /* LogoHeader.swift */; };
4D9B3B422C36E23A00A8F7AD /* Array+RawRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B412C36E23A00A8F7AD /* Array+RawRepresentable.swift */; };
4D9B3B452C36F46F00A8F7AD /* NSTextContentType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B442C36F46F00A8F7AD /* NSTextContentType.swift */; };
4D9B3B472C36F50300A8F7AD /* UITextContentType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9B3B462C36F50300A8F7AD /* UITextContentType.swift */; };
4D9DC5032C11BF2500BA0507 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D9DC5022C11BF2500BA0507 /* Config.swift */; };
Expand Down Expand Up @@ -143,7 +142,6 @@
4D9B3B372C334B3A00A8F7AD /* LoginScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreen.swift; sourceTree = "<group>"; };
4D9B3B392C334B6300A8F7AD /* RegisterScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterScreen.swift; sourceTree = "<group>"; };
4D9B3B3C2C34B13E00A8F7AD /* LogoHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoHeader.swift; sourceTree = "<group>"; };
4D9B3B412C36E23A00A8F7AD /* Array+RawRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+RawRepresentable.swift"; sourceTree = "<group>"; };
4D9B3B442C36F46F00A8F7AD /* NSTextContentType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSTextContentType.swift; sourceTree = "<group>"; };
4D9B3B462C36F50300A8F7AD /* UITextContentType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITextContentType.swift; sourceTree = "<group>"; };
4D9DC5022C11BF2500BA0507 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
Expand All @@ -152,6 +150,7 @@
4DB10B4F2C4FEBFC00634BF6 /* HelpCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpCommands.swift; sourceTree = "<group>"; };
4DB2E36C2C416611007F958D /* SubmitButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubmitButton.swift; sourceTree = "<group>"; };
4DB2E36E2C418F5C007F958D /* DynamicForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicForm.swift; sourceTree = "<group>"; };
4DBF0BD32C9DB2E500E797BF /* .ios-test-model */ = {isa = PBXFileReference; lastKnownFileType = text; path = ".ios-test-model"; sourceTree = "<group>"; };
4DC5B1C92C6FA23000B75A07 /* LoginScreenProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginScreenProtocol.swift; sourceTree = "<group>"; };
4DC5B1CC2C6FA28E00B75A07 /* RegisterScreenProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterScreenProtocol.swift; sourceTree = "<group>"; };
4DC5B1CE2C6FA2BE00B75A07 /* MainViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewProtocol.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -289,6 +288,7 @@
4DF3737F2C99C23D0008AB04 /* .swift-format */,
4D0DDC292C18A467006CD503 /* .xcode-version */,
4D6641DB2C5B963500BE3D07 /* .ios-test-version */,
4DBF0BD32C9DB2E500E797BF /* .ios-test-model */,
4DCEF8652C452EBA00F53085 /* .env-example */,
4DCEF8662C452ECC00F53085 /* .env */,
4D54C9592BF266F9001DE071 /* Makefile */,
Expand Down Expand Up @@ -410,7 +410,6 @@
isa = PBXGroup;
children = (
4DE785812C88B248000EC4E5 /* String.swift */,
4D9B3B412C36E23A00A8F7AD /* Array+RawRepresentable.swift */,
4D9B3B442C36F46F00A8F7AD /* NSTextContentType.swift */,
4D9B3B462C36F50300A8F7AD /* UITextContentType.swift */,
4DE785872C88F392000EC4E5 /* HTTPField.swift */,
Expand Down Expand Up @@ -641,7 +640,6 @@
4D13AF7B2C4E8F4200845FDB /* EnvironmentPicker.swift in Sources */,
4D30DA5F2C986B6C00499450 /* Avatar.swift in Sources */,
4DC5B1CF2C6FA2BE00B75A07 /* MainViewProtocol.swift in Sources */,
4D9B3B422C36E23A00A8F7AD /* Array+RawRepresentable.swift in Sources */,
4D4D394A2C086DA2007196D2 /* PublishedScreen.swift in Sources */,
4D5251EC2C1097A600018CD2 /* Destination.swift in Sources */,
4D54C92E2BF2608A001DE071 /* MainView.swift in Sources */,
Expand Down Expand Up @@ -791,6 +789,7 @@
ONLY_ACTIVE_ARCH = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -854,6 +853,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_VERSION = 6.0;
};
name = Release;
};
Expand Down Expand Up @@ -889,7 +889,6 @@
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -926,7 +925,6 @@
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -942,7 +940,6 @@
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Fyreplace.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Fyreplace";
};
Expand All @@ -959,7 +956,6 @@
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Fyreplace.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Fyreplace";
};
Expand All @@ -975,7 +971,6 @@
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = Fyreplace;
};
Expand All @@ -991,7 +986,6 @@
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = Fyreplace;
};
Expand Down
4 changes: 2 additions & 2 deletions Fyreplace/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import OpenAPIURLSession
import SwiftUI

struct Config {
static var `default` = Config(from: Bundle.main)
static let `default` = Config(from: Bundle.main)

let version: Version
let app: App
Expand Down Expand Up @@ -127,7 +127,7 @@ extension [String: Any] {
}

private struct ConfigEnvironmentKey: EnvironmentKey {
static var defaultValue = Config(from: Bundle.main)
static let defaultValue = Config(from: Bundle.main)
}

extension EnvironmentValues {
Expand Down
2 changes: 1 addition & 1 deletion Fyreplace/Data/AuthenticationMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct AuthenticationMiddleware: ClientMiddleware {
next: @Sendable (HTTPRequest, HTTPBody?, URL) async throws -> (HTTPResponse, HTTPBody?)
) async throws -> (HTTPResponse, HTTPBody?) {
var request = request
let token = KeychainCache.shared(for: "connection.token").value
let token = await KeychainCache.shared(for: "connection.token").value

if !token.isEmpty {
request.headerFields[.authorization] = "Bearer \(token)"
Expand Down
2 changes: 2 additions & 0 deletions Fyreplace/Data/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ actor KeychainActor: GlobalActor {
static let shared = KeychainActor()
}

@MainActor
@propertyWrapper
struct KeychainStorage: DynamicProperty {
@ObservedObject
Expand Down Expand Up @@ -81,6 +82,7 @@ struct KeychainStorage: DynamicProperty {
}
}

@MainActor
class KeychainCache: ObservableObject {
private static var instances: [String: KeychainCache] = [:]

Expand Down
14 changes: 9 additions & 5 deletions Fyreplace/Events/Event.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import SwiftUI

protocol Event {}
@MainActor
protocol Event: Sendable {}

@MainActor
protocol UnfortunateEvent: Event {}

struct ErrorEvent: UnfortunateEvent {
let error: UnexpectedError
struct ErrorEvent: UnfortunateEvent, LocalizedError {
static let defaultDescription: String.LocalizationValue = "Error.Unknown"

init(_ error: UnexpectedError) {
self.error = error
var description = defaultDescription

var errorDescription: String {
.init(localized: description)
}
}

Expand Down
18 changes: 0 additions & 18 deletions Fyreplace/Extensions/Array+RawRepresentable.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Fyreplace/Views/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct MainView: View, MainViewProtocol {
var showFailure = false

@State
var errors: [UnexpectedError] = []
var errors: [ErrorEvent] = []

@State
var failures: [FailureEvent] = []
Expand Down Expand Up @@ -55,7 +55,7 @@ struct MainView: View, MainViewProtocol {
Text(failure.text)
}
)
.onReceive(eventBus.events.compactMap { ($0 as? ErrorEvent)?.error }, perform: addError)
.onReceive(eventBus.events.compactMap { ($0 as? ErrorEvent) }, perform: addError)
.onReceive(eventBus.events.compactMap { ($0 as? FailureEvent) }, perform: addFailure)
.onReceive(eventBus.events.filter { $0 is AuthorizationIssueEvent }) { _ in
token = ""
Expand Down
7 changes: 5 additions & 2 deletions Fyreplace/Views/MainViewProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import Foundation

@MainActor
protocol MainViewProtocol: ViewProtocol {
var showError: Bool { get nonmutating set }
var showFailure: Bool { get nonmutating set }
var errors: [UnexpectedError] { get nonmutating set }
var errors: [ErrorEvent] { get nonmutating set }
var failures: [FailureEvent] { get nonmutating set }
}

@MainActor
extension MainViewProtocol {
func addError(_ error: UnexpectedError) {
func addError(_ error: ErrorEvent) {
errors.append(error)
tryShowSomething()
}
Expand Down
2 changes: 1 addition & 1 deletion Fyreplace/Views/Navigation/CompactNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct CompactNavigation: View, NavigationProtocol {
@SceneStorage("CompactNavigation.selectedDestination")
private var selectedDestination = Destination.feed

@SceneStorage("CompactNavigation.selectedChoices")
@State
private var selectedChoices = Destination.essentials

@AppStorage("account.isRegistering")
Expand Down
4 changes: 2 additions & 2 deletions Fyreplace/Views/Navigation/Destination.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

public enum Destination: String, Codable, Identifiable {
enum Destination: String, Identifiable {
case feed
case notifications
case archive
Expand All @@ -10,7 +10,7 @@ public enum Destination: String, Codable, Identifiable {
case login
case register

public var id: String {
var id: String {
.init(reflecting: self)
}

Expand Down
1 change: 1 addition & 0 deletions Fyreplace/Views/Navigation/NavigationProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation

@MainActor
protocol NavigationProtocol {
var eventBus: EventBus { get }

Expand Down
9 changes: 6 additions & 3 deletions Fyreplace/Views/Screens/LoginScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ struct LoginScreen: View, LoginScreenProtocol {
}
}

@available(macOS 14.0, *)
@available(iOS 17.0, *)
#Preview {
NavigationStack {
@Namespace
var namespace
@Previewable
@Namespace
var namespace

NavigationStack {
LoginScreen(namespace: namespace)
}
.environmentObject(EventBus())
Expand Down
5 changes: 3 additions & 2 deletions Fyreplace/Views/Screens/LoginScreenProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@MainActor
protocol LoginScreenProtocol: LoadingViewProtocol {
var api: APIProtocol { get }

Expand Down Expand Up @@ -52,7 +53,7 @@ extension LoginScreenProtocol {
)

case .default:
return .error(UnknownError())
return .error()
}
}

Expand Down Expand Up @@ -90,7 +91,7 @@ extension LoginScreenProtocol {
)

case .default:
return .error(UnknownError())
return .error()
}
}
}
9 changes: 6 additions & 3 deletions Fyreplace/Views/Screens/RegisterScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,14 @@ struct RegisterScreen: View, RegisterScreenProtocol {
}
}

@available(macOS 14.0, *)
@available(iOS 17.0, *)
#Preview {
NavigationStack {
@Namespace
var namespace
@Previewable
@Namespace
var namespace

NavigationStack {
RegisterScreen(namespace: namespace)
}
.environmentObject(EventBus())
Expand Down
5 changes: 3 additions & 2 deletions Fyreplace/Views/Screens/RegisterScreenProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@MainActor
protocol RegisterScreenProtocol: LoadingViewProtocol {
var api: APIProtocol { get }

Expand Down Expand Up @@ -84,7 +85,7 @@ extension RegisterScreenProtocol {
}

case .default:
return .error(UnknownError())
return .error()
}
}

Expand Down Expand Up @@ -124,7 +125,7 @@ extension RegisterScreenProtocol {
)

case .default:
return .error(UnknownError())
return .error()
}
}
}
3 changes: 2 additions & 1 deletion Fyreplace/Views/Screens/SettingsScreenProtocol.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@MainActor
protocol SettingsScreenProtocol: ViewProtocol {
var api: APIProtocol { get }

Expand All @@ -23,7 +24,7 @@ extension SettingsScreenProtocol {
return .authorizationIssue()

case .forbidden, .default:
return .error(UnknownError())
return .error()
}
}
}
Expand Down
Loading

0 comments on commit 5158199

Please sign in to comment.