Skip to content

Commit 2dc2756

Browse files
authored
swift 6 updates across the board (#45)
* swift 6 updates across the board * macOS 15 runner for CI * iOS version match for Xcode 16
1 parent 0f0248b commit 2dc2756

File tree

54 files changed

+302
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+302
-302
lines changed

.github/workflows/swift.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@ on:
99
jobs:
1010
build:
1111

12-
runs-on: macos-14
12+
runs-on: macos-15
1313
strategy:
1414
matrix:
1515
run-config:
16-
- { scheme: 'Lindenmayer-Package', destination: 'platform=iOS Simulator,OS=15.5,name=iPhone 8' }
17-
# Xcode on Github Actions supports at best up to macOS 11.6.2 currently...
18-
- { scheme: 'Lindenmayer-Package', destination: 'platform=macOS,arch=x86_64' }
16+
- { scheme: 'Lindenmayer-Package', destination: 'platform=iOS Simulator,OS=18.1,name=iPhone 16' }
17+
- { scheme: 'Lindenmayer-Package', destination: 'platform=macOS' }
1918

2019
steps:
2120
- uses: actions/checkout@v4
2221

23-
# default Xcode for macOS 14 image is v15.0.1
24-
- name: Select Xcode 15.3
25-
run: sudo xcode-select -s /Applications/Xcode_15.3.app
26-
2722
- name: Show Build SDK
2823
run: xcodebuild -showsdks
2924

LICENSE

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

3-
Copyright (c) 2021 Joseph Heck
3+
Copyright (c) 2021-2024 Joseph Heck
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Package.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
import PackageDescription
44

5+
var globalSwiftSettings: [PackageDescription.SwiftSetting] = [
6+
.enableExperimentalFeature("StrictConcurrency"),
7+
.enableUpcomingFeature("ExistentialAny"),
8+
.enableExperimentalFeature("AccessLevelOnImport"),
9+
.enableUpcomingFeature("InternalImportsByDefault"),
10+
]
11+
512
let package = Package(
613
name: "Lindenmayer",
714
platforms: [
@@ -19,22 +26,23 @@ let package = Package(
1926
],
2027
dependencies: [
2128
.package(url: "https://github.com/heckj/SceneKitDebugTools.git", from: "0.1.0"),
22-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
29+
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.0.0"),
2330
],
2431
targets: [
2532
.target(
2633
name: "Lindenmayer",
2734
dependencies: ["SceneKitDebugTools"],
28-
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
35+
swiftSettings: globalSwiftSettings
2936
),
3037
.target(
3138
name: "LindenmayerViews",
3239
dependencies: ["Lindenmayer", "SceneKitDebugTools"],
33-
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
40+
swiftSettings: globalSwiftSettings
3441
),
3542
.testTarget(
3643
name: "LindenmayerTests",
3744
dependencies: ["Lindenmayer", "SceneKitDebugTools"]
3845
),
39-
]
46+
],
47+
swiftLanguageVersions: [.version("6"), .v5]
4048
)

Sources/Lindenmayer/Examples/Examples2D.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public enum Examples2D {
1515
struct Internode: Module {
1616
// This is the kind of thing that I want external developers using the library to be able to create to represent elements within their L-system.
1717
public var name = "I"
18-
public var render2D: [TwoDRenderCmd] = [RenderCommand.Draw(length: 10)] // draws a line 10 units long
18+
public var render2D: [any TwoDRenderCmd] = [RenderCommand.Draw(length: 10)] // draws a line 10 units long
1919
public init() {}
2020
}
2121

@@ -48,7 +48,7 @@ public enum Examples2D {
4848
struct Leaf: Module {
4949
static let green = ColorRepresentation(r: 0.3, g: 0.56, b: 0.0)
5050
public var name = "L"
51-
public var render2D: [TwoDRenderCmd] = [
51+
public var render2D: [any TwoDRenderCmd] = [
5252
RenderCommand.SetLineWidth(width: 3),
5353
RenderCommand.SetColor(representation: green),
5454
RenderCommand.Draw(length: 5),
@@ -59,7 +59,7 @@ public enum Examples2D {
5959

6060
struct Stem: Module {
6161
public var name = "I"
62-
public var render2D: [TwoDRenderCmd] = [RenderCommand.Draw(length: 5)] // would be neat to make this green...
62+
public var render2D: [any TwoDRenderCmd] = [RenderCommand.Draw(length: 5)] // would be neat to make this green...
6363
}
6464

6565
static let stem = Stem()
@@ -99,14 +99,14 @@ public enum Examples2D {
9999

100100
struct F: Module {
101101
public var name = "F"
102-
public var render2D: [TwoDRenderCmd] = [RenderCommand.Draw(length: 10)]
102+
public var render2D: [any TwoDRenderCmd] = [RenderCommand.Draw(length: 10)]
103103
}
104104

105105
static let f = F()
106106

107107
struct G: Module {
108108
public var name = "G"
109-
public var render2D: [TwoDRenderCmd] = [RenderCommand.Draw(length: 10)]
109+
public var render2D: [any TwoDRenderCmd] = [RenderCommand.Draw(length: 10)]
110110
}
111111

112112
static let g = G()

Sources/Lindenmayer/Examples/Examples3D.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public enum Examples3D: Sendable {
4141

4242
struct Cyl: Module {
4343
public var name = "C"
44-
public var render3D: ThreeDRenderCmd = RenderCommand.Cylinder(
44+
public var render3D: any ThreeDRenderCmd = RenderCommand.Cylinder(
4545
length: 10,
4646
radius: 1,
4747
color: ColorRepresentation(red: 1.0, green: 0.1, blue: 0.1, alpha: 1.0)
@@ -50,7 +50,7 @@ public enum Examples3D: Sendable {
5050

5151
struct S: Module {
5252
public var name = "S"
53-
public var render3D: ThreeDRenderCmd = RenderCommand.Cylinder(
53+
public var render3D: any ThreeDRenderCmd = RenderCommand.Cylinder(
5454
length: 5,
5555
radius: 2,
5656
color: ColorRepresentation(red: 0.1, green: 1.0, blue: 0.1, alpha: 1.0)
@@ -146,7 +146,7 @@ public enum Examples3D: Sendable {
146146

147147
struct StaticTrunk: Module {
148148
public var name = ""
149-
public var render3D: ThreeDRenderCmd {
149+
public var render3D: any ThreeDRenderCmd {
150150
RenderCommand.Cylinder(
151151
length: growthDistance,
152152
radius: diameter / 2,
@@ -395,7 +395,7 @@ public enum Examples3D: Sendable {
395395
struct Stem2: Module {
396396
public var name = "i"
397397
let length: Double // start at 10
398-
public var render3D: ThreeDRenderCmd {
398+
public var render3D: any ThreeDRenderCmd {
399399
RenderCommand.Cylinder(
400400
length: length,
401401
radius: length / 10,
@@ -407,7 +407,7 @@ public enum Examples3D: Sendable {
407407
struct StaticStem2: Module {
408408
public var name = "I"
409409
let length: Double // start at 10
410-
public var render3D: ThreeDRenderCmd {
410+
public var render3D: any ThreeDRenderCmd {
411411
RenderCommand.Cylinder(
412412
length: length,
413413
radius: length / 10,
@@ -417,19 +417,19 @@ public enum Examples3D: Sendable {
417417
}
418418

419419
public static let randomBush = LSystem.create(Stem2(length: 1), with: Xoshiro(seed: 42))
420-
.rewriteWithRNG(directContext: Stem2.self) { stem, rng async -> [Module] in
420+
.rewriteWithRNG(directContext: Stem2.self) { stem, rng async -> [any Module] in
421421

422422
let upper: Float = 45.0
423423
let lower: Float = 15.0
424424

425-
if await rng.p(0.5) {
426-
return await [
425+
if rng.p(0.5) {
426+
return [
427427
StaticStem2(length: 2),
428428
Modules.PitchDown(angle: Angle(degrees: Double(rng.randomFloat(in: lower ... upper)))),
429429
Stem2(length: stem.length),
430430
]
431431
} else {
432-
return await [
432+
return [
433433
StaticStem2(length: 2),
434434
Modules.PitchUp(angle: Angle(degrees: Double(rng.randomFloat(in: lower ... upper)))),
435435
Stem2(length: stem.length),

Sources/Lindenmayer/LSystem.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ public enum LSystem: Sendable {
4040
/// Creates a new Lindenmayer system from an initial state.
4141
/// - Parameters:
4242
/// - axiom: An initial module that represents the initial state of the Lindenmayer system..
43-
public static func create(_ axiom: Module) -> ContextualLSystem {
43+
public static func create(_ axiom: some Module) -> ContextualLSystem {
4444
ContextualLSystem([axiom], state: nil, newStateIndicators: nil)
4545
}
4646

4747
/// Creates a new Lindenmayer system from an initial state.
4848
/// - Parameters:
4949
/// - axiom: A sequence of modules that represents the initial state of the Lindenmayer system..
50-
public static func create(_ axiom: [Module]) -> ContextualLSystem {
50+
public static func create(_ axiom: [any Module]) -> ContextualLSystem {
5151
ContextualLSystem(axiom, state: nil, newStateIndicators: nil)
5252
}
5353

5454
/// Creates a new Lindenmayer system from an initial state and using the random number generator you provide.
5555
/// - Parameters:
5656
/// - axiom: An initial module that represents the initial state of the Lindenmayer system..
5757
/// - prng: An optional psuedo-random number generator to use for randomness in rule productions.
58-
public static func create<RNGType: Sendable>(_ axiom: Module, with prng: RNGType?) -> RandomContextualLSystem<RNGType> {
58+
public static func create<RNGType: Sendable>(_ axiom: some Module, with prng: RNGType?) -> RandomContextualLSystem<RNGType> {
5959
if let prng {
6060
return RandomContextualLSystem(axiom: [axiom], state: nil, newStateIndicators: nil, prng: RNGWrapper(prng))
6161
}
@@ -66,7 +66,7 @@ public enum LSystem: Sendable {
6666
/// - Parameters:
6767
/// - axiom: A sequence of modules that represents the initial state of the Lindenmayer system..
6868
/// - prng: An optional psuedo-random number generator to use for for randomness in rule productions.
69-
public static func create<RNGType: Sendable>(_ axiom: [Module], with prng: RNGType?) -> RandomContextualLSystem<RNGType> {
69+
public static func create<RNGType: Sendable>(_ axiom: [any Module], with prng: RNGType?) -> RandomContextualLSystem<RNGType> {
7070
if let prng {
7171
return RandomContextualLSystem(axiom: axiom, state: nil, newStateIndicators: nil, prng: RNGWrapper(prng))
7272
}
@@ -78,7 +78,7 @@ public enum LSystem: Sendable {
7878
/// - axiom: An initial module that represents the initial state of the Lindenmayer system.
7979
/// - prng: An optional psuedo-random number generator to use for for randomness in rule productions.
8080
/// - parameters: An instance of type you provide that the L-system provides to the rules you create for use as parameters.
81-
public static func create<PType: Sendable, RNGType: Sendable>(_ axiom: Module, with prng: RNGType?, using parameters: PType) -> ParameterizedRandomContextualLSystem<PType, RNGType> {
81+
public static func create<PType: Sendable, RNGType: Sendable>(_ axiom: some Module, with prng: RNGType?, using parameters: PType) -> ParameterizedRandomContextualLSystem<PType, RNGType> {
8282
if let prng {
8383
return ParameterizedRandomContextualLSystem(axiom: [axiom], state: nil, newStateIndicators: nil, parameters: parameters, prng: RNGWrapper(prng), rules: [])
8484
}
@@ -90,7 +90,7 @@ public enum LSystem: Sendable {
9090
/// - axiom: A sequence of modules that represents the initial state of the Lindenmayer system..
9191
/// - prng: An optional psuedo-random number generator to use for for randomness in rule productions.
9292
/// - parameters: An instance of type you provide that the L-system provides to the rules you create for use as parameters.
93-
public static func create<PType: Sendable, RNGType: Sendable>(_ axiom: [Module], with prng: RNGType?, using parameters: PType) -> ParameterizedRandomContextualLSystem<PType, RNGType> {
93+
public static func create<PType: Sendable, RNGType: Sendable>(_ axiom: [any Module], with prng: RNGType?, using parameters: PType) -> ParameterizedRandomContextualLSystem<PType, RNGType> {
9494
if let prng {
9595
return ParameterizedRandomContextualLSystem(axiom: axiom, state: nil, newStateIndicators: nil, parameters: parameters, prng: RNGWrapper(prng), rules: [])
9696
}

0 commit comments

Comments
 (0)