Skip to content

Commit

Permalink
Swift 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NikSativa committed Sep 27, 2024
1 parent 13eb2e1 commit ec2d4dc
Show file tree
Hide file tree
Showing 26 changed files with 808 additions and 346 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/swift_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "NikSativa CI"

on:
push:
branches:
- "main"
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"
pull_request:
paths:
- ".github/workflows/**"
- "Package.swift"
- "Source/**"
- "Tests/**"

concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
jobs:
macOS:
name: "macOS ${{ matrix.xcode }} ${{ matrix.swift }}"
runs-on: ${{ matrix.runsOn }}
env:
DEVELOPER_DIR: "/Applications/${{ matrix.xcode }}.app/Contents/Developer"
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- xcode: "Xcode_16"
runsOn: macOS-15
swift: "6.0"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_15.4"
runsOn: macOS-14
swift: "5.10"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_15.2"
runsOn: macOS-14
swift: "5.9"
outputFilter: xcbeautify --renderer github-actions
- xcode: "Xcode_14.3"
runsOn: macOS-13
swift: "5.8"
outputFilter: xcbeautify --renderer github-actions
steps:
- uses: NeedleInAJayStack/setup-swift@feat/swift-6 # swift-actions/setup-swift@main
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: "Build ${{ matrix.xcode }} ${{ matrix.swift }}"
run: swift build -v | ${{ matrix.outputFilter }}
- name: "Test ${{ matrix.xcode }} ${{ matrix.swift }}"
run: swift test -v | ${{ matrix.outputFilter }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Pods/*
Carthage/*
Packages/*
.swiftpm/*
Package.resolved

## Bundler
.bundle/
Expand Down
8 changes: 8 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This is manifest file for the Swift Package Index for it to
# auto-generate and host DocC documentation.
# For reference see https://swiftpackageindex.com/swiftpackageindex/spimanifest/documentation/spimanifest/commonusecases#Host-DocC-documentation-in-the-Swift-Package-Index.

version: 1
builder:
configs:
- documentation_targets: [Threading]
32 changes: 0 additions & 32 deletions Package.resolved

This file was deleted.

25 changes: 6 additions & 19 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0
// swiftformat:disable all
import PackageDescription

Expand All @@ -8,38 +8,25 @@ let package = Package(
.iOS(.v13),
.macOS(.v11),
.macCatalyst(.v13),
.visionOS(.v1),
.tvOS(.v13),
.watchOS(.v6)
.watchOS(.v6),
.visionOS(.v1)
],
products: [
.library(name: "Threading", targets: ["Threading"]),
.library(name: "ThreadingTestHelpers", targets: ["ThreadingTestHelpers"])
.library(name: "Threading", targets: ["Threading"])
],
dependencies: [
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "2.2.3"))
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "3.0.0"))
],
targets: [
.target(name: "Threading",
dependencies: [
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
]),
.target(name: "ThreadingTestHelpers",
dependencies: [
"Threading",
"SpryKit"
],
path: "TestHelpers",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "ThreadingTests",
dependencies: [
"Threading",
"ThreadingTestHelpers",
"SpryKit"
],
path: "Tests")
Expand Down
46 changes: 0 additions & 46 deletions [email protected]

This file was deleted.

46 changes: 0 additions & 46 deletions [email protected]

This file was deleted.

17 changes: 2 additions & 15 deletions [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,19 @@ let package = Package(
],
products: [
.library(name: "Threading", targets: ["Threading"]),
.library(name: "ThreadingTestHelpers", targets: ["ThreadingTestHelpers"])
],
dependencies: [
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "2.2.3"))
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "3.0.0"))
],
targets: [
.target(name: "Threading",
dependencies: [
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
]),
.target(name: "ThreadingTestHelpers",
dependencies: [
"Threading",
"SpryKit"
],
path: "TestHelpers",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "ThreadingTests",
dependencies: [
"Threading",
"ThreadingTestHelpers",
"SpryKit"
],
path: "Tests")
Expand Down
22 changes: 5 additions & 17 deletions [email protected][email protected]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.5
// swift-tools-version:5.9
// swiftformat:disable all
import PackageDescription

Expand All @@ -9,36 +9,24 @@ let package = Package(
.macOS(.v11),
.macCatalyst(.v13),
.tvOS(.v13),
.watchOS(.v6)
.watchOS(.v6),
.visionOS(.v1)
],
products: [
.library(name: "Threading", targets: ["Threading"]),
.library(name: "ThreadingTestHelpers", targets: ["ThreadingTestHelpers"])
],
dependencies: [
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "2.2.3"))
.package(url: "https://github.com/NikSativa/SpryKit.git", .upToNextMajor(from: "3.0.0"))
],
targets: [
.target(name: "Threading",
dependencies: [
],
path: "Source",
resources: [
.copy("../PrivacyInfo.xcprivacy")
]),
.target(name: "ThreadingTestHelpers",
dependencies: [
"Threading",
"SpryKit"
],
path: "TestHelpers",
resources: [
.copy("../PrivacyInfo.xcprivacy")
.process("PrivacyInfo.xcprivacy")
]),
.testTarget(name: "ThreadingTests",
dependencies: [
"Threading",
"ThreadingTestHelpers",
"SpryKit"
],
path: "Tests")
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Queue.main.sync {

### Queueable
Protocol can help you test your code without threading by overriding real implementation via your own mock or existing Fake from SpryKit framework.

### DelayedQueue
Make it simple to manage task execution as parameter at your discretion. You can manage not only in what Queue to execute but also how - sync or async.

Expand All @@ -38,3 +39,35 @@ you can never go wrong with creating a queue due to explicit parameters
```swift
Queue.custom(label: “my line”, attributes: .serial).async
```

### Concurrency workarounds

Some times very difficult to avoid concurrency isolation issues. This is a simple solution to avoid it. Just use isolatedMain queue to execute your task on the main thread without any side effects.

```swift
Queue.isolatedMain.sync {
// your task on main thread
}

Queue.isolatedMain.sync {
// or return value from main thread
return 42
}

Queue.isolatedMain.sync {
// or throw error from main thread
return try someThrowingFunction()
}
```

UnSendable - is a struct that helps you to avoid concurrency check of non-Sendable objects (ex. using UI elements). It is not a silver bullet, but it can help you to avoid some issues.
> [!WARNING]
> **Use at your own risk.**
```swift
let unsafe = UnSendable(ImageView())
Queue.main.async {
let view = unsafe.value
// make your magic
}
```
Loading

0 comments on commit ec2d4dc

Please sign in to comment.