Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Swift 6 when available & upgrade to Xcode 16.2 #331

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ permissions:
contents: read
jobs:
build-eliza-cocoapods-example:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install xcbeautify
run: brew install xcbeautify
- name: Build Eliza CocoaPods example
Expand All @@ -23,69 +23,69 @@ jobs:
pod install
set -o pipefail && xcodebuild -workspace ElizaCocoaPodsApp.xcworkspace -scheme ElizaCocoaPodsApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify
build-eliza-swiftpm-example:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install xcbeautify
run: brew install xcbeautify
- name: Build Eliza Swift PM example
run: |
cd Examples/ElizaSwiftPackageApp
set -o pipefail && xcodebuild -scheme ElizaSwiftPackageApp build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify
build-library-ios:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install xcbeautify
run: brew install xcbeautify
- name: Build Connect iOS library
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=iOS Simulator,name=iPhone 16,OS=18.0' | xcbeautify
build-library-macos:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install xcbeautify
run: brew install xcbeautify
- name: Build Connect macOS library
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=macOS' | xcbeautify
build-library-tvos:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install xcbeautify
run: brew install xcbeautify
- name: Build Connect tvOS library
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=tvOS Simulator,name=Apple TV,OS=18.0' | xcbeautify
build-library-watchos:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install xcbeautify
run: brew install xcbeautify
- name: Build Connect watchOS library
run: set -o pipefail && xcodebuild -scheme Connect-Package -destination 'platform=watchOS Simulator,name=Apple Watch Series 10 (42mm),OS=11.0' | xcbeautify
build-plugin-and-generate:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
run: sudo xcode-select --switch /Applications/Xcode_15.2.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
Expand All @@ -98,26 +98,26 @@ jobs:
git update-index --refresh --add --remove
git diff-index --quiet HEAD --
run-conformance-tests:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Install conformance runner
run: make installconformancerunner
- name: Run conformance tests
run: make testconformance
run-unit-tests:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Run unit tests
run: make testunit
run-swiftlint:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ permissions:
contents: write
jobs:
release:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- uses: bufbuild/[email protected]
with:
github_token: ${{ github.token }}
Expand All @@ -37,12 +37,12 @@ jobs:
files: |
./.tmp/bin/artifacts/*
publish-podspecs:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Select Xcode version
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.app
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-arm64-Readme.md#xcode
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
- name: Publish podspecs to CocoaPods
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand Down Expand Up @@ -413,7 +413,7 @@
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we may want to do instead is keep the swift-tools-version set at 5.6 and then specify swiftLanguageVersions: [.version("6"), .v5] (instead of swiftLanguageModes which is new and Swift 6/Xcode 16 only).

What this will do is allow us to compile with Swift 6 when using the package in Xcode 16, but it will continue to let the package compile with Xcode 15.4 as well. (docs here). I think that's what we want, because if we increase the required swift-tools-version, I believe that would technically be considered a breaking change, since any dependent packages that are also set to 5.6 would need to increase their tools version to at least the value specified by Connect-Swift.

I could also be wrong here, but just wanted to share that since I've also been going through this exercise of updating some of my packages to compile with Swift 6 while still wanting them to be usable on Xcode 15.4.

Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this writeup @eseay.

I think you're correct based on the docs you linked, particularly the section on:

If instead you would just like to use Swift 6 language mode when it’s available (while still continuing to support older modes) you can keep a single Package.swift and specify the version in a compatible manner

I pushed an update with your recommendation 🙏🏽

Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ let package = Package(
path: "Plugins/ConnectSwiftPlugin"
),
],
swiftLanguageVersions: [.v5]
swiftLanguageVersions: [.version("6"), .v5]
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// DO NOT EDIT.
// swift-format-ignore-file
// swiftlint:disable all
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: connectrpc/conformance/v1/client_compat.proto
Expand Down Expand Up @@ -38,7 +39,7 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
/// these from stdin and, for each one, invokes an RPC as directed
/// and writes the results (in the form of a ClientCompatResponse
/// message) to stdout.
struct Connectrpc_Conformance_V1_ClientCompatRequest {
struct Connectrpc_Conformance_V1_ClientCompatRequest: @unchecked Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand Down Expand Up @@ -230,7 +231,7 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest {

var unknownFields = SwiftProtobuf.UnknownStorage()

struct Cancel {
struct Cancel: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand Down Expand Up @@ -300,7 +301,7 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest {
/// after all request messages are sent and the send side is
/// closed (as if the after_close_send_ms field were present
/// and zero).
enum OneOf_CancelTiming: Equatable {
enum OneOf_CancelTiming: Equatable, Sendable {
/// When present, the client should cancel *instead of*
/// closing the send side of the stream, after all requests
/// have been sent.
Expand Down Expand Up @@ -332,28 +333,6 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest {
/// This applies only to server and bidi stream RPCs.
case afterNumResponses(UInt32)

#if !swift(>=4.1)
static func ==(lhs: Connectrpc_Conformance_V1_ClientCompatRequest.Cancel.OneOf_CancelTiming, rhs: Connectrpc_Conformance_V1_ClientCompatRequest.Cancel.OneOf_CancelTiming) -> Bool {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch (lhs, rhs) {
case (.beforeCloseSend, .beforeCloseSend): return {
guard case .beforeCloseSend(let l) = lhs, case .beforeCloseSend(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.afterCloseSendMs, .afterCloseSendMs): return {
guard case .afterCloseSendMs(let l) = lhs, case .afterCloseSendMs(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.afterNumResponses, .afterNumResponses): return {
guard case .afterNumResponses(let l) = lhs, case .afterNumResponses(let r) = rhs else { preconditionFailure() }
return l == r
}()
default: return false
}
}
#endif
}

init() {}
Expand All @@ -365,7 +344,7 @@ struct Connectrpc_Conformance_V1_ClientCompatRequest {
}

/// The outcome of one ClientCompatRequest.
struct Connectrpc_Conformance_V1_ClientCompatResponse {
struct Connectrpc_Conformance_V1_ClientCompatResponse: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand Down Expand Up @@ -411,36 +390,18 @@ struct Connectrpc_Conformance_V1_ClientCompatResponse {
/// (e.g. a unary request that defines zero or multiple request messages).
///
/// However, once the RPC is issued, any resulting error should instead be encoded in response.
enum OneOf_Result: Equatable {
enum OneOf_Result: Equatable, Sendable {
case response(Connectrpc_Conformance_V1_ClientResponseResult)
case error(Connectrpc_Conformance_V1_ClientErrorResult)

#if !swift(>=4.1)
static func ==(lhs: Connectrpc_Conformance_V1_ClientCompatResponse.OneOf_Result, rhs: Connectrpc_Conformance_V1_ClientCompatResponse.OneOf_Result) -> Bool {
// The use of inline closures is to circumvent an issue where the compiler
// allocates stack space for every case branch when no optimizations are
// enabled. https://github.com/apple/swift-protobuf/issues/1034
switch (lhs, rhs) {
case (.response, .response): return {
guard case .response(let l) = lhs, case .response(let r) = rhs else { preconditionFailure() }
return l == r
}()
case (.error, .error): return {
guard case .error(let l) = lhs, case .error(let r) = rhs else { preconditionFailure() }
return l == r
}()
default: return false
}
}
#endif
}

init() {}
}

/// The result of a ClientCompatRequest, which may or may not be successful.
/// The client will build this message and return it back to the test runner.
struct Connectrpc_Conformance_V1_ClientResponseResult {
struct Connectrpc_Conformance_V1_ClientResponseResult: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand Down Expand Up @@ -505,7 +466,7 @@ struct Connectrpc_Conformance_V1_ClientResponseResult {
/// The client is not able to fulfill the ClientCompatRequest. This may be due
/// to a runtime error or an unexpected internal error such as the requested protocol
/// not being supported. This is completely independent of the actual RPC invocation.
struct Connectrpc_Conformance_V1_ClientErrorResult {
struct Connectrpc_Conformance_V1_ClientErrorResult: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -523,7 +484,7 @@ struct Connectrpc_Conformance_V1_ClientErrorResult {
/// Details about various values as observed on the wire. This message is used
/// only by the reference client when reporting results and should not be populated
/// by clients under test.
struct Connectrpc_Conformance_V1_WireDetails {
struct Connectrpc_Conformance_V1_WireDetails: Sendable {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand Down Expand Up @@ -571,17 +532,6 @@ struct Connectrpc_Conformance_V1_WireDetails {
fileprivate var _actualGrpcwebTrailers: String? = nil
}

#if swift(>=5.5) && canImport(_Concurrency)
extension Connectrpc_Conformance_V1_ClientCompatRequest: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_ClientCompatRequest.Cancel: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_ClientCompatRequest.Cancel.OneOf_CancelTiming: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_ClientCompatResponse: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_ClientCompatResponse.OneOf_Result: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_ClientResponseResult: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_ClientErrorResult: @unchecked Sendable {}
extension Connectrpc_Conformance_V1_WireDetails: @unchecked Sendable {}
#endif // swift(>=5.5) && canImport(_Concurrency)

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "connectrpc.conformance.v1"
Expand Down Expand Up @@ -633,7 +583,15 @@ extension Connectrpc_Conformance_V1_ClientCompatRequest: SwiftProtobuf.Message,
var _cancel: Connectrpc_Conformance_V1_ClientCompatRequest.Cancel? = nil
var _rawRequest: Connectrpc_Conformance_V1_RawHTTPRequest? = nil

static let defaultInstance = _StorageClass()
#if swift(>=5.10)
// This property is used as the initial default value for new instances of the type.
// The type itself is protecting the reference to its storage via CoW semantics.
// This will force a copy to be made of this reference when the first mutation occurs;
// hence, it is safe to mark this as `nonisolated(unsafe)`.
static nonisolated(unsafe) let defaultInstance = _StorageClass()
#else
static let defaultInstance = _StorageClass()
#endif

private init() {}

Expand Down
Loading
Loading