Skip to content

Commit

Permalink
Enable Swift 6 Language Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Nov 4, 2024
1 parent 03d82c2 commit 3d1bd04
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 49 deletions.
31 changes: 26 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

//
// This source file is part of the Stanford Spezi open-source project
Expand All @@ -8,6 +8,7 @@
// SPDX-License-Identifier: MIT
//

import class Foundation.ProcessInfo
import PackageDescription


Expand All @@ -21,8 +22,8 @@ let package = Package(
.library(name: "SpeziMedication", targets: ["SpeziMedication"])
],
dependencies: [
.package(url: "https://github.com/StanfordSpezi/SpeziViews", from: "1.2.0")
],
.package(url: "https://github.com/StanfordSpezi/SpeziViews", from: "1.7.0")
] + swiftLintPackage(),
targets: [
.target(
name: "SpeziMedication",
Expand All @@ -31,13 +32,33 @@ let package = Package(
],
resources: [
.process("Resources")
]
],
plugins: [] + swiftLintPlugin()
),
.testTarget(
name: "SpeziMedicationTests",
dependencies: [
.target(name: "SpeziMedication")
]
],
plugins: [] + swiftLintPlugin()
)
]
)


func swiftLintPlugin() -> [Target.PluginUsage] {
// Fully quit Xcode and open again with `open --env SPEZI_DEVELOPMENT_SWIFTLINT /Applications/Xcode.app`
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLint")]
} else {
[]
}
}

func swiftLintPackage() -> [PackageDescription.Package.Dependency] {
if ProcessInfo.processInfo.environment["SPEZI_DEVELOPMENT_SWIFTLINT"] != nil {
[.package(url: "https://github.com/realm/SwiftLint.git", from: "0.55.1")]
} else {
[]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation


extension String: LocalizedError {
extension String: @retroactive LocalizedError {
public var errorDescription: String? {
self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI


struct ScheduledTimeDatePicker: UIViewRepresentable {
@MainActor
class Coordinator: NSObject {
private var lastDate: Date
private let date: Binding<Date>
Expand Down
1 change: 1 addition & 0 deletions Sources/SpeziMedication/MedicationSettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public protocol MedicationSettingsViewModel<Medications>: Observable {
///
/// Be sure that the ``medicationInstances`` property is updated with the resulting set of medications.
/// - Parameter medications: The set of medications to be persisted.
@MainActor
func persist(medicationInstances: Set<Medications>) async throws
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/SpeziMedication/Models/Weekdays.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import Foundation


public struct Weekdays: OptionSet, Codable, Hashable, CaseIterable, Identifiable {
public static var allCases: [Weekdays] = [.monday, .tuesday, .wednesday, .thursday, .friday, .saturday, .sunday]
public struct Weekdays: OptionSet, Codable, Hashable, CaseIterable, Identifiable, Sendable {
public static let allCases: [Weekdays] = [.monday, .tuesday, .wednesday, .thursday, .friday, .saturday, .sunday]

static let sunday = Weekdays(rawValue: 1 << 0)
static let monday = Weekdays(rawValue: 1 << 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ struct ScheduleFrequencyView: View {
}

#Preview {
@State var frequency: Frequency = .specificDaysOfWeek(.all)
@State var startDate: Date = .now
@Previewable @State var frequency: Frequency = .specificDaysOfWeek(.all)
@Previewable @State var startDate: Date = .now

return ScheduleFrequencyView(frequency: $frequency, startDate: $startDate)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SwiftUI
class ExampleMedicationSettingsViewModel: Module, MedicationSettingsViewModel, CustomStringConvertible {
var medicationInstances: Set<ExampleMedicationInstance> = []
let medicationOptions: Set<ExampleMedication>


var description: String {
guard !medicationInstances.isEmpty else {
Expand Down
46 changes: 9 additions & 37 deletions Tests/UITests/UITests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 77;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -141,7 +141,6 @@
2F6D138F28F5F384007C25D6 /* Frameworks */,
2F6D139028F5F384007C25D6 /* Resources */,
2F9CBECE2A76C412009818FF /* Embed Watch Content */,
2FA84E6A2B153BC900F59E0C /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -182,7 +181,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1610;
TargetAttributes = {
2F6D139128F5F384007C25D6 = {
CreatedOnToolsVersion = 14.1;
Expand All @@ -194,7 +193,6 @@
};
};
buildConfigurationList = 2F6D138D28F5F384007C25D6 /* Build configuration list for PBXProject "UITests" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand All @@ -205,6 +203,7 @@
packageReferences = (
97B786B82B717396004066DB /* XCRemoteSwiftPackageReference "Spezi" */,
);
preferredProjectObjectVersion = 77;
productRefGroup = 2F6D139328F5F384007C25D6 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -233,27 +232,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2FA84E6A2B153BC900F59E0C /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"${CONFIGURATION}\" = \"Debug\" ]; then\n export PATH=\"$PATH:/opt/homebrew/bin\"\n if which swiftlint > /dev/null; then\n cd ../../ && swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
2F6D138E28F5F384007C25D6 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -325,6 +303,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -348,6 +327,7 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 6.0;
};
name = Debug;
};
Expand Down Expand Up @@ -388,6 +368,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand All @@ -404,14 +385,14 @@
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 6.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
2F6D13B728F5F386007C25D6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -440,15 +421,13 @@
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
2F6D13B828F5F386007C25D6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -477,15 +456,13 @@
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
2F6D13BD28F5F386007C25D6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
Expand All @@ -500,7 +477,6 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = TestApp;
};
Expand All @@ -509,7 +485,6 @@
2F6D13BE28F5F386007C25D6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
Expand All @@ -524,7 +499,6 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = TestApp;
};
Expand Down Expand Up @@ -567,6 +541,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -590,13 +565,13 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = TEST;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 6.0;
};
name = Test;
};
2FB07588299DDB6000C0B37F /* Test */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -625,15 +600,13 @@
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Test;
};
2FB07589299DDB6000C0B37F /* Test */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 637867499T;
Expand All @@ -648,7 +621,6 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = TestApp;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
LastUpgradeVersion = "1610"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down

0 comments on commit 3d1bd04

Please sign in to comment.