Skip to content

Commit

Permalink
SWIFT_STRICT_CONCURRENCY = complete (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong committed Apr 17, 2024
1 parent e7ae92a commit 0ea4c3b
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: LunarBarMac
runs-on: macos-14
env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_15.3.app/Contents/Developer

steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 8 additions & 0 deletions LunarBar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
8740E30B2B37F969004A06C2 /* EventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8740E30A2B37F969004A06C2 /* EventView.swift */; };
8740E30F2B37FB36004A06C2 /* CalendarManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8740E30E2B37FB36004A06C2 /* CalendarManager.swift */; };
8740E31B2B39210F004A06C2 /* AppPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8740E31A2B39210F004A06C2 /* AppPreferences.swift */; };
874D77772BCF94900093662D /* Unchecked.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874D77762BCF94900093662D /* Unchecked.swift */; };
874E992D2B33D8C0002FC90A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 874E992C2B33D8C0002FC90A /* AppDelegate.swift */; };
874E99312B33D8C1002FC90A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 874E99302B33D8C1002FC90A /* Assets.xcassets */; };
875A81282B39558000C031C3 /* AppVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 875A81262B39558000C031C3 /* AppVersion.swift */; };
Expand Down Expand Up @@ -63,6 +64,7 @@
8740E30A2B37F969004A06C2 /* EventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventView.swift; sourceTree = "<group>"; };
8740E30E2B37FB36004A06C2 /* CalendarManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarManager.swift; sourceTree = "<group>"; };
8740E31A2B39210F004A06C2 /* AppPreferences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppPreferences.swift; sourceTree = "<group>"; };
874D77762BCF94900093662D /* Unchecked.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Unchecked.swift; sourceTree = "<group>"; };
874E99292B33D8C0002FC90A /* LunarBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LunarBar.app; sourceTree = BUILT_PRODUCTS_DIR; };
874E992C2B33D8C0002FC90A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
874E99302B33D8C1002FC90A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -199,6 +201,7 @@
8740E2FD2B37C823004A06C2 /* Managers */,
8782F4752B33F8EF008B1912 /* Views */,
875A81252B39558000C031C3 /* Updater */,
874D77762BCF94900093662D /* Unchecked.swift */,
);
path = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -372,6 +375,7 @@
875A81282B39558000C031C3 /* AppVersion.swift in Sources */,
8782F46F2B33F627008B1912 /* AppDefinitions.swift in Sources */,
8740E31B2B39210F004A06C2 /* AppPreferences.swift in Sources */,
874D77772BCF94900093662D /* Unchecked.swift in Sources */,
87F81C542B43EBDE0071CA30 /* main.swift in Sources */,
87DA5AFF2B3433D400CE2C1A /* WeekdayView.swift in Sources */,
8740E2FF2B37C841004A06C2 /* HolidayManager.swift in Sources */,
Expand Down Expand Up @@ -484,6 +488,7 @@
"DEBUG=1",
"$(inherited)",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -498,6 +503,7 @@
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
};
name = Debug;
};
Expand Down Expand Up @@ -544,6 +550,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_NO_COMMON_BLOCKS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -556,6 +563,7 @@
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_STRICT_CONCURRENCY = complete;
};
name = Release;
};
Expand Down
3 changes: 3 additions & 0 deletions LunarBarKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ let package = Package(
resources: [
.process("LunarCalendar/Resources"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
],
plugins: [
.plugin(name: "SwiftLint", package: "LunarBarTools"),
]
Expand Down
2 changes: 1 addition & 1 deletion LunarBarKit/Sources/LunarCalendar/LunarCalendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
For example, solar terms are hard to be precise if we compute them using formulas.
*/
public final class LunarCalendar {
public final class LunarCalendar: Sendable {
public static let `default` = LunarCalendar()

/**
Expand Down
9 changes: 9 additions & 0 deletions LunarBarKit/Sources/Unchecked.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// Unchecked.swift
//
// Created by cyan on 2024/4/17.
//

import os.log

extension os.Logger: @unchecked Sendable {}
4 changes: 3 additions & 1 deletion LunarBarMac/Sources/Main/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

let silentlyCheckUpdates = {
let silentlyCheckUpdates: @Sendable () -> Void = {
Task {
await AppUpdater.checkForUpdates(explicitly: false)
}
Expand Down Expand Up @@ -122,6 +122,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return false
}

@MainActor
func updateMenuBarIcon(needsLayout: Bool = false) {
switch AppPreferences.General.menuBarIcon {
case .calendar:
Expand All @@ -148,6 +149,7 @@ extension AppDelegate: NSPopoverDelegate {

// MARK: - Private

@MainActor
private extension AppDelegate {
// periphery:ignore:parameters notification
@objc func calendarDayDidChange(_ notification: Notification) {
Expand Down
1 change: 1 addition & 0 deletions LunarBarMac/Sources/Managers/CalendarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import LunarBarKit
/**
For the native Calendar app.
*/
@MainActor
final class CalendarManager {
static let `default` = CalendarManager()

Expand Down
7 changes: 4 additions & 3 deletions LunarBarMac/Sources/Managers/HolidayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum HolidayType: Int {
/**
For public holidays.
*/
@MainActor
final class HolidayManager {
static let `default` = HolidayManager()

Expand Down Expand Up @@ -83,7 +84,7 @@ final class HolidayManager {
return nil
}

func fetchDefaultHolidays() async {
nonisolated func fetchDefaultHolidays() async {
guard let url = URL(string: Constants.endpoint) else {
return Logger.assertFail("Failed to create the URL: \(Constants.endpoint)")
}
Expand All @@ -103,15 +104,15 @@ final class HolidayManager {
Logger.log(.info, "Successfully fetched default holidays")

do {
try data.write(
try await data.write(
to: cachesDirectory.appending(
path: url.lastPathComponent,
directoryHint: .notDirectory
),
options: .atomic
)

reloadCachedFiles()
await reloadCachedFiles()
} catch {
Logger.log(.error, error.localizedDescription)
}
Expand Down
1 change: 1 addition & 0 deletions LunarBarMac/Sources/Shared/AppIconFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import AppKit

@MainActor
enum AppIconFactory {
static func createCalendarIcon(pointSize: Double = 16) -> NSImage {
.with(symbolName: Icons.calendar, pointSize: pointSize).asTemplate
Expand Down
4 changes: 3 additions & 1 deletion LunarBarMac/Sources/Shared/AppPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum AppPreferences {
@Storage(key: "accessibility.reduce-transparency", defaultValue: false)
static var reduceTransparency: Bool

static var popoverMaterial: NSVisualEffectView.Material {
@MainActor static var popoverMaterial: NSVisualEffectView.Material {
reduceTransparency ? .windowBackground : .menu
}
}
Expand All @@ -68,6 +68,7 @@ enum Appearance: Codable {
case light
case dark

@MainActor
func resolved(with appearance: NSAppearance = NSApp.effectiveAppearance) -> NSAppearance? {
switch self {
case .system:
Expand All @@ -80,6 +81,7 @@ enum Appearance: Codable {
}
}

@MainActor
@propertyWrapper
struct Storage<T: Codable> {
private let key: String
Expand Down
10 changes: 10 additions & 0 deletions LunarBarMac/Sources/Unchecked.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Unchecked.swift
// LunarBarMac
//
// Created by cyan on 2024/4/17.
//

import EventKit

extension EKEventStore: @unchecked Sendable {}
1 change: 1 addition & 0 deletions LunarBarMac/Sources/Updater/AppUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum AppUpdater {

// MARK: - Private

@MainActor
private extension AppUpdater {
static func presentError() {
let alert = NSAlert()
Expand Down
1 change: 1 addition & 0 deletions LunarBarMac/Sources/Views/HeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AppKit
import AppKitControls
import LunarBarKit

@MainActor
protocol HeaderViewDelegate: AnyObject {
func headerView(_ sender: HeaderView, moveTo date: Date)
func headerView(_ sender: HeaderView, moveBy offset: Int)
Expand Down

0 comments on commit 0ea4c3b

Please sign in to comment.