Skip to content

Commit

Permalink
Preliminary fixes for SWIFT_STRICT_CONCURRENCY = complete
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmidt committed Feb 12, 2024
1 parent c464ae9 commit 08db074
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Refracto.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1200;
LastUpgradeCheck = 1500;
LastUpgradeCheck = 1520;
TargetAttributes = {
4D44ADFF2513FE5300ED5142 = {
CreatedOnToolsVersion = 12.0;
Expand Down Expand Up @@ -650,6 +650,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
};
name = Debug;
};
Expand Down Expand Up @@ -705,6 +706,7 @@
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_STRICT_CONCURRENCY = complete;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions Refracto/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

// MARK: - Haptic Feedback

@MainActor
fileprivate var generator: UIImpactFeedbackGenerator? = nil

extension AppDelegate {
Expand Down
1 change: 1 addition & 0 deletions Refracto/Formatters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension NumberFormatter {
}
}

@MainActor
struct Formatter {
static var brix: NumberFormatter = {
formatter("#0.0")
Expand Down
10 changes: 4 additions & 6 deletions Refracto/RefractometerDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RefractometerDisplay: ReadableWidthView {
}

deinit {
unregisterUpdateNotifications()
NotificationCenter.default.removeObserver(self)
}

override var intrinsicContentSize: CGSize {
Expand All @@ -40,14 +40,12 @@ extension RefractometerDisplay {
let notification = Settings.updateNotification
let main = OperationQueue.main
NotificationCenter.default.addObserver(forName: notification, object: nil, queue: main) { [weak self] _ in
self?.update()
Task { @MainActor [weak self] in
self?.update()
}
}
}

private func unregisterUpdateNotifications() {
NotificationCenter.default.removeObserver(self)
}

func update() {
switch Settings.shared.displayScheme {
case .Modern:
Expand Down
1 change: 1 addition & 0 deletions Refracto/RefractometerModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Foundation

@MainActor
final class RefractometerModel: NSObject {
static var originalExtract: Double {
let s = Settings.shared
Expand Down
1 change: 1 addition & 0 deletions Refracto/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ enum AppIcon: String, Codable, ItemPickable {
extension AppIcon {
static let defaultIcon: AppIcon = .IconGreen

@MainActor
static var current: Self {
guard let id = UIApplication.shared.alternateIconName, let icon = AppIcon(rawValue: id) else { return Self.defaultIcon }
return icon
Expand Down
18 changes: 11 additions & 7 deletions Refracto/SettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ enum SupportRow: Int, CaseIterable {
}


@MainActor
fileprivate func canSendMail() -> Bool {
return MFMailComposeViewController.canSendMail()
}

@MainActor
fileprivate func supportsAlternateIcons() -> Bool {
return UIApplication.shared.supportsAlternateIcons
}
Expand Down Expand Up @@ -92,13 +94,15 @@ extension SettingsController {
// MARK: - MFMailComposeViewControllerDelegate

extension SettingsController : MFMailComposeViewControllerDelegate {
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
dismiss(animated: true) {
if result == .failed {
let ok = UIAlertAction(title: "OK", style: .default)
let alert = UIAlertController(title: "MailFailedTitle".localized, message: "MailFailedMessage".localized, preferredStyle: .alert)
alert.addAction(ok)
self.present(alert, animated: true)
nonisolated func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
Task { @MainActor in
dismiss(animated: true) {
if result == .failed {
let ok = UIAlertAction(title: "OK", style: .default)
let alert = UIAlertController(title: "MailFailedTitle".localized, message: "MailFailedMessage".localized, preferredStyle: .alert)
alert.addAction(ok)
self.present(alert, animated: true)
}
}
}
}
Expand Down

1 comment on commit 08db074

@m-schmidt
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining warnings seem to be caused by not yet updated UIAccessibilityTraits API.

https://www.openradar.appspot.com/FB12152347

Please sign in to comment.