Skip to content

Commit a0c5ae4

Browse files
authored
Merge pull request #36 from noppefoxwolf/swift6
Supports sendable & actor
2 parents 65188f3 + 99eccb4 commit a0c5ae4

31 files changed

Lines changed: 81 additions & 60 deletions

.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version: 5.9
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "DebugMenu",
88
defaultLocalization: "en",
9-
platforms: [.iOS(.v14)],
9+
platforms: [.iOS(.v16)],
1010
products: [
1111
.library(
1212
name: "DebugMenu",

Sources/DebugMenu/DebugMenu.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import UIKit
22

33
@available(iOSApplicationExtension, unavailable)
44
public struct DebugMenu {
5+
6+
@MainActor
57
public static func install(
68
windowScene: UIWindowScene? = nil,
79
items: [DebugItem] = [],

Sources/DebugMenu/Entity/Application.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

33
public class Application {
4-
public static var current: Application = .init()
4+
public static var current: Application { Application() }
55

66
public var appName: String {
77
Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String

Sources/DebugMenu/Entity/DashboardItem.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22

3-
public protocol DashboardItem {
3+
@MainActor
4+
public protocol DashboardItem: Sendable {
45
var title: String { get }
56
func startMonitoring()
67
func stopMonitoring()
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import UIKit
22

3-
public protocol DebugItem {
3+
public protocol DebugItem: Sendable {
44
var debugItemTitle: String { get }
55
var action: DebugItemAction { get }
66
}
77

8-
public enum DebugItemAction {
8+
public enum DebugItemAction: Sendable {
99
case didSelect(
10-
operation: (_ controller: UIViewController) async -> DebugMenuResult
10+
operation: @Sendable @MainActor (_ controller: UIViewController) async -> DebugMenuResult
1111
)
12-
case execute(_ operation: () async -> DebugMenuResult)
12+
case execute(_ operation: @Sendable () async -> DebugMenuResult)
1313
case toggle(
14-
current: () -> Bool,
15-
operation: (_ isOn: Bool) async -> DebugMenuResult
14+
current: @Sendable () -> Bool,
15+
operation: @Sendable (_ isOn: Bool) async -> DebugMenuResult
1616
)
1717
case slider(
18-
current: () -> Double,
19-
valueLabelText: (Double) -> String,
18+
current: @Sendable () -> Double,
19+
valueLabelText: @Sendable (Double) -> String,
2020
range: ClosedRange<Double>,
21-
operation: (_ value: Double) async -> DebugMenuResult
21+
operation: @Sendable (_ value: Double) async -> DebugMenuResult
2222
)
2323
}

Sources/DebugMenu/Entity/Device.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import UIKit
22

3-
public class Device {
4-
public static let current: Device = .init()
3+
@MainActor
4+
public final class Device {
5+
public static var current: Device { Device() }
56

67
public var localizedModel: String {
78
UIDevice.current.localizedModel

Sources/DebugMenu/Entity/Device/GPU.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Foundation
22
import Metal
33

4-
class GPU {
5-
static var current: GPU = .init()
4+
final class GPU {
5+
static var current: GPU { GPU() }
66
let device: MTLDevice
77

88
init() {

Sources/DebugMenu/Entity/Device/NetworkUsage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct NetworkUsage {
3+
public struct NetworkUsage: Sendable {
44
public let wifiDataSent: UInt64
55
public let wifiDataReceived: UInt64
66
public let wwanDataSent: UInt64
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

3-
public enum MetricsFetcher {
4-
case text(_ fetcher: () -> String)
5-
case graph(_ fetcher: () -> [Double])
6-
case interval(_ fetcher: () -> [TimeInterval])
3+
public enum MetricsFetcher: Sendable {
4+
case text(_ fetcher: @Sendable @MainActor () -> String)
5+
case graph(_ fetcher: @Sendable @MainActor () -> [Double])
6+
case interval(_ fetcher: @Sendable @MainActor () -> [TimeInterval])
77
}

0 commit comments

Comments
 (0)