Skip to content

Commit

Permalink
Add Swift 6.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Sep 18, 2024
1 parent a09c25a commit bce98e0
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/swift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand Down
12 changes: 3 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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<SwiftSetting> = [
.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(
Expand Down
48 changes: 48 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -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<SwiftSetting> = [
.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),
]
)
2 changes: 1 addition & 1 deletion [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let swiftSettings: Array<SwiftSetting> = [
.enableUpcomingFeature("BareSlashRegexLiterals"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency"),
// .enableExperimentalFeature("AccessLevelOnImport"),
.enableExperimentalFeature("AccessLevelOnImport"),
// .enableExperimentalFeature("VariadicGenerics"),
]

Expand Down
9 changes: 4 additions & 5 deletions Sources/DeviceInformation/DeviceInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(_ work: @MainActor () -> T) -> T {
func _assumeIsolated<T: Sendable>(_ work: @MainActor () -> T) -> T {
#if swift(>=5.10)
if #available(iOS 13, tvOS 13, *) {
return MainActor.assumeIsolated(work)
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion Sources/DeviceInformation/PlatformIdentifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -230,7 +238,6 @@ extension DeviceInfo {
// MARK: AirTags
"AirTag1,1" : "AirTags",


// MARK: Macs
"iMac21,1" : "iMac 24\" M1",
"iMac21,2" : "iMac 24\" M1",
Expand Down

0 comments on commit bce98e0

Please sign in to comment.