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

Trivially enable async/await with Xcode 13.2.1 on Big Sur #2994

Closed
mteep opened this issue Apr 4, 2023 · 5 comments
Closed

Trivially enable async/await with Xcode 13.2.1 on Big Sur #2994

mteep opened this issue Apr 4, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@mteep
Copy link

mteep commented Apr 4, 2023

Currently Vapor cannot be built with async/await support using Xcode 13.2.1, which is the last version of Xcode supported on macOS Big Sur.

This is despite the fact that if Vapor is built with a later Xcode version, with async/await, it can still run on Big Sur. And also despite the fact that Xcode 13.2.1 contains everything actually needed to build Vapor with async/await.

A simple change to Package.swift in Vapor (and related packages like async-kit, fluent and fluent-kit) would fix this issue. An issue that seems to stem from uncertainty about what the swift-tools-version means.

Xcode 13.2.1 includes Swift 5.5.2, but the SwiftPM version is still 5.5.0, for reasons unknown to me. (There is a standalone build of Swift 5.5.3 for macOS, with no changes except bumping the versions of both Swift and SwiftPM to 5.5.3. The Swift part of this build can be used with Xcode 13.2.1, but that doesn't affect the SwiftPM support in Xcode.)

I'm not sure why Vapor wants Swift 5.5.2 over Swift 5.5, but if that distinction is important to Vapor (it isn't to Swift-NIO, as some people seem to claim), it can be expressed in the Package.swift file, without requiring SwiftPM beyond 5.5.

One way is to take advantage of the Swift version supported by the compiler compiling Package.swift. I have an example of that in a branch called mergeable-big-sur.

@mteep mteep added the enhancement New feature or request label Apr 4, 2023
@mteep
Copy link
Author

mteep commented Apr 4, 2023

Something like this:

// swift-tools-version:5.5
import PackageDescription

// Workaround for Xcode 13.2(.1) with Swift 5.5.2, but SwiftPM 5.5.0
#if swift(>=5.5.2)
let platforms: [SupportedPlatform] = [
    .macOS(.v10_15),
    .iOS(.v13),
    .tvOS(.v13),
    .watchOS(.v6)
]
#else
let platforms: [SupportedPlatform] = [
    .macOS(.v12),
    .iOS(.v15),
    .tvOS(.v15),
    .watchOS(.v8)
]
#endif

let package = Package(
    name: "vapor",
    platforms: platforms,
    products:

@mteep mteep changed the title Enable async/await with Xcode 13.2.1 on Big Sur? Trivially enable async/await with Xcode 13.2.1 on Big Sur Apr 5, 2023
@0xTim
Copy link
Member

0xTim commented Apr 11, 2023

Just to clarify this as the PR is closed - 5.5.2 ensures that anyone building on Xcode 13.0 and 13.1 would correctly take an older version of Vapor that worked with these releases. 5.5.2 ensures that the concurrency runtime is bundled with the toolchain otherwise you'd get weird errors

@0xTim 0xTim closed this as completed Apr 11, 2023
@mteep
Copy link
Author

mteep commented Apr 11, 2023

By "weird errors", do you mean that the final product needs to ensure that the rpath needs to be able to locate the concurrency library? That is correct, but simple to work around.

@mteep
Copy link
Author

mteep commented Apr 11, 2023

A simpler way, if Swift 5.5.2 actually is needed by Vapor, would be to include everything in the manifest in a #if swift(>=5.5.2), so that the version of Swift, and not SwiftPM, is tested.

Something like:

// swift-tools-version:5.5
import PackageDescription

// Workaround for Xcode 13.2(.1) with Swift 5.5.2, but SwiftPM 5.5.0
#if swift(>=5.5.2)

... Everything in the current manifest ...

#endif

@0xTim
Copy link
Member

0xTim commented Apr 11, 2023

Yes if on macOS 13.0 there was no Concurrency runtime to link against so even manually setting an rpath wouldn't help without all kinds of hacks. This has been superseded by #2996 anyway as we need it for some Sendable stuff that's upcoming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants