diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 89b885b..6361f00 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -20,7 +20,7 @@ jobs: uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-generate-and-publish-docs.yml@main with: os: macOS - swift-version: '5.10' + swift-version: '6.0' organisation: ${{ github.repository_owner }} repository: ${{ github.event.repository.name }} pages-branch: gh-pages diff --git a/.github/workflows/swift-test.yml b/.github/workflows/swift-test.yml index e935fef..66f5e6c 100644 --- a/.github/workflows/swift-test.yml +++ b/.github/workflows/swift-test.yml @@ -12,10 +12,10 @@ permissions: jobs: variables: outputs: - max-supported-swift-version: '5.10' + max-supported-swift-version: '6.0' xcode-scheme: apple-device-information xcode-platform-version: latest - fail-if-codecov-fails: true + fail-if-codecov-fails: 'true' runs-on: ubuntu-latest steps: - run: exit 0 @@ -25,7 +25,7 @@ jobs: strategy: matrix: os: [ macOS ] - swift-version-offset: [ 0, 1 ] + swift-version-offset: [ 0, 1, 2 ] uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-spm.yml@main with: os: ${{ matrix.os }} @@ -46,7 +46,7 @@ jobs: - tvOS - watchOS - visionOS - swift-version-offset: [ 0, 1 ] + swift-version-offset: [ 0, 1, 2 ] uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-test-xcode.yml@main with: xcode-scheme: ${{ needs.variables.outputs.xcode-scheme }} diff --git a/Package.swift b/Package.swift index db14ffb..7cf00af 100644 --- a/Package.swift +++ b/Package.swift @@ -1,19 +1,13 @@ -// swift-tools-version:5.10 +// swift-tools-version:6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let swiftSettings: Array = [ - .enableUpcomingFeature("ConciseMagicFile"), + .swiftLanguageMode(.v6), .enableUpcomingFeature("ExistentialAny"), - .enableUpcomingFeature("BareSlashRegexLiterals"), - .enableUpcomingFeature("DisableOutwardActorInference"), - .enableUpcomingFeature("IsolatedDefaultValues"), - .enableUpcomingFeature("DeprecateApplicationMain"), - .enableExperimentalFeature("StrictConcurrency"), + .enableUpcomingFeature("InternalImportsByDefault"), .enableExperimentalFeature("GlobalConcurrency"), -// .enableExperimentalFeature("AccessLevelOnImport"), -// .enableExperimentalFeature("VariadicGenerics"), ] let package = Package( diff --git a/Package@swift-5.10.swift b/Package@swift-5.10.swift new file mode 100644 index 0000000..dc40ff3 --- /dev/null +++ b/Package@swift-5.10.swift @@ -0,0 +1,48 @@ +// swift-tools-version:5.10 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let swiftSettings: Array = [ + .enableUpcomingFeature("ConciseMagicFile"), + .enableUpcomingFeature("ExistentialAny"), + .enableUpcomingFeature("BareSlashRegexLiterals"), + .enableUpcomingFeature("DisableOutwardActorInference"), + .enableUpcomingFeature("IsolatedDefaultValues"), + .enableUpcomingFeature("DeprecateApplicationMain"), + .enableExperimentalFeature("StrictConcurrency"), + .enableExperimentalFeature("GlobalConcurrency"), + .enableExperimentalFeature("AccessLevelOnImport"), +// .enableExperimentalFeature("VariadicGenerics"), +] + +let package = Package( + name: "apple-device-information", + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "DeviceInformation", + targets: ["DeviceInformation"]), + ], + dependencies: [ + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), + .package(url: "https://github.com/sersoft-gmbh/swift-sysctl", from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "DeviceInformation", + dependencies: [ + .product(name: "Sysctl", package: "swift-sysctl"), + ], + swiftSettings: swiftSettings), + .testTarget( + name: "DeviceInformationTests", + dependencies: [ + .product(name: "Sysctl", package: "swift-sysctl"), + "DeviceInformation", + ], + swiftSettings: swiftSettings), + ] +) diff --git a/Package@swift-5.9.swift b/Package@swift-5.9.swift index a9891db..0defb19 100644 --- a/Package@swift-5.9.swift +++ b/Package@swift-5.9.swift @@ -9,7 +9,7 @@ let swiftSettings: Array = [ .enableUpcomingFeature("BareSlashRegexLiterals"), .enableUpcomingFeature("DisableOutwardActorInference"), .enableExperimentalFeature("StrictConcurrency"), -// .enableExperimentalFeature("AccessLevelOnImport"), + .enableExperimentalFeature("AccessLevelOnImport"), // .enableExperimentalFeature("VariadicGenerics"), ] diff --git a/Sources/DeviceInformation/DeviceInfo.swift b/Sources/DeviceInformation/DeviceInfo.swift index dc527b4..9de9d23 100644 --- a/Sources/DeviceInformation/DeviceInfo.swift +++ b/Sources/DeviceInformation/DeviceInfo.swift @@ -24,7 +24,7 @@ public struct DeviceInfo: Sendable, Equatable, Identifiable { #elseif canImport(UIKit) && !targetEnvironment(macCatalyst) // os(iOS) os(tvOS) os(visionOS) @MainActor func _access() -> String { UIDevice.current.systemName } - func _assumeIsolated(_ work: @MainActor () -> T) -> T { + func _assumeIsolated(_ work: @MainActor () -> T) -> T { #if swift(>=5.10) if #available(iOS 13, tvOS 13, *) { return MainActor.assumeIsolated(work) @@ -39,9 +39,9 @@ public struct DeviceInfo: Sendable, Equatable, Identifiable { } } if Thread.isMainThread { - return _assumeIsolated(_access) + return _assumeIsolated { _access() } } else { - return DispatchQueue.main.sync { _assumeIsolated(_access) } + return DispatchQueue.main.sync { _assumeIsolated { _access() } } } #elseif os(macOS) || targetEnvironment(macCatalyst) return "macOS" @@ -106,8 +106,7 @@ extension DeviceInfo { #if arch(arm64) || arch(x86_64) #if canImport(Combine) && canImport(SwiftUI) -import Combine -import SwiftUI +public import SwiftUI @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension DeviceInfo { diff --git a/Sources/DeviceInformation/PlatformIdentifiers.swift b/Sources/DeviceInformation/PlatformIdentifiers.swift index fa68a68..82da462 100644 --- a/Sources/DeviceInformation/PlatformIdentifiers.swift +++ b/Sources/DeviceInformation/PlatformIdentifiers.swift @@ -56,6 +56,10 @@ extension DeviceInfo { "iPhone15,5" : "iPhone 15 Plus", "iPhone16,1" : "iPhone 15 Pro", "iPhone16,2" : "iPhone 15 Pro Max", + "iPhone17,3" : "iPhone 16", + "iPhone17,4" : "iPhone 16 Plus", + "iPhone17,1" : "iPhone 16 Pro", + "iPhone17,2" : "iPhone 16 Pro Max", // MARK: Watch "Watch1,1" : "Apple Watch 38mm", @@ -102,6 +106,10 @@ extension DeviceInfo { "Watch7,3" : "Apple Watch Series 9 41mm (Cellular)", "Watch7,4" : "Apple Watch Series 9 45mm (Cellular)", "Watch7,5" : "Apple Watch Ultra 2 49mm", + "Watch7,8" : "Apple Watch Series 10 42mm", + "Watch7,9" : "Apple Watch Series 10 46mm", + "Watch7,10" : "Apple Watch Series 10 42mm (Cellular)", + "Watch7,11" : "Apple Watch Series 10 46mm (Cellular)", // MARK: iPod "iPod1,1" : "iPod Touch 1G", @@ -230,7 +238,6 @@ extension DeviceInfo { // MARK: AirTags "AirTag1,1" : "AirTags", - // MARK: Macs "iMac21,1" : "iMac 24\" M1", "iMac21,2" : "iMac 24\" M1",