Skip to content

Commit b74fe84

Browse files
wip fix the way we specify swift version
TODO it doesn't seem to be picking up the example app version
1 parent 407058a commit b74fe84

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

.github/workflows/check.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: swift run BuildTool generate-matrices >> $GITHUB_OUTPUT
4444

4545
check-spm:
46-
name: SPM (Xcode ${{ matrix.tooling.xcodeVersion }}, Swift ${{ matrix.tooling.swiftVersion }})
46+
name: SPM (Xcode ${{ matrix.tooling.xcodeVersion }})
4747
runs-on: macos-latest
4848
needs: generate-matrices
4949
strategy:
@@ -57,11 +57,11 @@ jobs:
5757
xcode-version: ${{ matrix.tooling.xcodeVersion }}
5858

5959
# https://forums.swift.org/t/warnings-as-errors-for-libraries-frameworks/58393/2
60-
- run: swift build -Xswiftc -warnings-as-errors -Xswiftc -swift-version -Xswiftc ${{ matrix.tooling.swiftVersion }}
61-
- run: swift test -Xswiftc -warnings-as-errors -Xswiftc -swift-version -Xswiftc ${{ matrix.tooling.swiftVersion }}
60+
- run: swift build -Xswiftc -warnings-as-errors
61+
- run: swift test -Xswiftc -warnings-as-errors
6262

6363
check-xcode:
64-
name: Xcode, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }}, Swift ${{ matrix.tooling.swiftVersion }})
64+
name: Xcode, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }})
6565
runs-on: macos-latest
6666
needs: generate-matrices
6767

@@ -76,7 +76,7 @@ jobs:
7676
xcode-version: ${{ matrix.tooling.xcodeVersion }}
7777

7878
- name: Build and run tests
79-
run: swift run BuildTool build-and-test-library --platform ${{ matrix.platform }} --swift-version ${{ matrix.tooling.swiftVersion }}
79+
run: swift run BuildTool build-and-test-library --platform ${{ matrix.platform }}
8080

8181
check-example-app:
8282
name: Example app, ${{matrix.platform}} (Xcode ${{ matrix.tooling.xcodeVersion }}, Swift ${{ matrix.tooling.swiftVersion }})

Example/AblyChatExample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
/* Begin PBXFileReference section */
1919
212F95A62C6CAD9300420287 /* MockRealtime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockRealtime.swift; sourceTree = "<group>"; };
20+
214AA9262C778FB70068FD0A /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
2021
21F09A9C2C60CAF00025AF73 /* AblyChatExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AblyChatExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
2122
21F09A9F2C60CAF00025AF73 /* AblyChatExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AblyChatExampleApp.swift; sourceTree = "<group>"; };
2223
21F09AA12C60CAF00025AF73 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -75,6 +76,7 @@
7576
212F95A52C6CAD7E00420287 /* Mocks */,
7677
21F09A9F2C60CAF00025AF73 /* AblyChatExampleApp.swift */,
7778
21F09AA12C60CAF00025AF73 /* ContentView.swift */,
79+
214AA9262C778FB70068FD0A /* Config.xcconfig */,
7880
21F09AA32C60CAF20025AF73 /* Assets.xcassets */,
7981
21F09AA52C60CAF20025AF73 /* AblyChatExample.entitlements */,
8082
21F09AA62C60CAF20025AF73 /* Preview Content */,
@@ -174,6 +176,7 @@
174176
/* Begin XCBuildConfiguration section */
175177
21F09AA92C60CAF20025AF73 /* Debug */ = {
176178
isa = XCBuildConfiguration;
179+
baseConfigurationReference = 214AA9262C778FB70068FD0A /* Config.xcconfig */;
177180
buildSettings = {
178181
ALWAYS_SEARCH_USER_PATHS = NO;
179182
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
@@ -238,6 +241,7 @@
238241
};
239242
21F09AAA2C60CAF20025AF73 /* Release */ = {
240243
isa = XCBuildConfiguration;
244+
baseConfigurationReference = 214AA9262C778FB70068FD0A /* Config.xcconfig */;
241245
buildSettings = {
242246
ALWAYS_SEARCH_USER_PATHS = NO;
243247
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This allows us to specify the Swift version on the command line without affecting the Swift version used for our dependencies (which it appears that specifying SWIFT_VERSION on the command line does).
2+
EXAMPLE_APP_SWIFT_VERSION = 5.0
3+
SWIFT_VERSION = $(EXAMPLE_APP_SWIFT_VERSION)

Sources/BuildTool/BuildTool.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ struct BuildAndTestLibrary: AsyncParsableCommand {
1919
static let configuration = CommandConfiguration(abstract: "Build and test the AblyChat library")
2020

2121
@Option var platform: Platform
22-
@Option var swiftVersion: Int
2322

2423
mutating func run() async throws {
2524
let destinationSpecifier = try await platform.resolve()
2625
let scheme = "AblyChat"
2726

28-
try await XcodeRunner.runXcodebuild(action: nil, scheme: scheme, destination: destinationSpecifier, swiftVersion: swiftVersion)
29-
try await XcodeRunner.runXcodebuild(action: "test", scheme: scheme, destination: destinationSpecifier, swiftVersion: swiftVersion)
27+
try await XcodeRunner.runXcodebuild(action: nil, scheme: scheme, destination: destinationSpecifier)
28+
try await XcodeRunner.runXcodebuild(action: "test", scheme: scheme, destination: destinationSpecifier)
3029
}
3130
}
3231

@@ -40,7 +39,7 @@ struct BuildExampleApp: AsyncParsableCommand {
4039
mutating func run() async throws {
4140
let destinationSpecifier = try await platform.resolve()
4241

43-
try await XcodeRunner.runXcodebuild(action: nil, scheme: "AblyChatExample", destination: destinationSpecifier, swiftVersion: swiftVersion)
42+
try await XcodeRunner.runXcodebuild(action: nil, scheme: "AblyChatExample", destination: destinationSpecifier, exampleAppSwiftVersion: swiftVersion)
4443
}
4544
}
4645

Sources/BuildTool/XcodeRunner.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
@available(macOS 14, *)
44
enum XcodeRunner {
5-
static func runXcodebuild(action: String?, scheme: String, destination: DestinationSpecifier, swiftVersion: Int) async throws {
5+
static func runXcodebuild(action: String?, scheme: String, destination: DestinationSpecifier, exampleAppSwiftVersion: Int? = nil) async throws {
66
var arguments: [String] = []
77

88
if let action {
@@ -11,11 +11,13 @@ enum XcodeRunner {
1111

1212
arguments.append(contentsOf: ["-scheme", scheme])
1313
arguments.append(contentsOf: ["-destination", destination.xcodebuildArgument])
14+
arguments.append("SWIFT_TREAT_WARNINGS_AS_ERRORS=YES")
1415

15-
arguments.append(contentsOf: [
16-
"SWIFT_TREAT_WARNINGS_AS_ERRORS=YES",
17-
"SWIFT_VERSION=\(swiftVersion)",
18-
])
16+
if let exampleAppSwiftVersion {
17+
arguments.append(
18+
"EXAMPLE_APP_SWIFT_VERSION=\(exampleAppSwiftVersion)"
19+
)
20+
}
1921

2022
try await ProcessRunner.run(executableName: "xcodebuild", arguments: arguments)
2123
}

0 commit comments

Comments
 (0)