Can you describe what do you do and what error do you get?
I run swift run
or the command from your comment:
in the 00-book-server directory and get
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:66:91: error: cannot find type 'Task' in scope
public func completeWithTask(_ body: @escaping @Sendable () async throws -> Value) -> Task<Void, Never> {
^~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:25:26: error: cannot find 'withUnsafeThrowingContinuation' in scope
return try await withUnsafeThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:43:26: error: cannot find 'withCheckedThrowingContinuation' in scope
return try await withCheckedThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[862/863] Compiling NIOCore AsyncAwaitSupport+OldXcodes.swift
error: fatalError
Could you please make sure you followed the steps I listed above - including cleaning the build directory and deleting the package lock file?
If you still get the same error, please let me know what’s the output of swift --version
so I can try to reproduce
Yep, I tried the cleaning steps as well, and here are the errors after the steps listed above:
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:66:91: error: cannot find type 'Task' in scope
public func completeWithTask(_ body: @escaping @Sendable () async throws -> Value) -> Task<Void, Never> {
^~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:25:26: error: cannot find 'withUnsafeThrowingContinuation' in scope
return try await withUnsafeThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:43:26: error: cannot find 'withCheckedThrowingContinuation' in scope
return try await withCheckedThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:66:91: error: cannot find type 'Task' in scope
public func completeWithTask(_ body: @escaping @Sendable () async throws -> Value) -> Task<Void, Never> {
^~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:25:26: error: cannot find 'withUnsafeThrowingContinuation' in scope
return try await withUnsafeThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:43:26: error: cannot find 'withCheckedThrowingContinuation' in scope
return try await withCheckedThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:66:91: error: cannot find type 'Task' in scope
public func completeWithTask(_ body: @escaping @Sendable () async throws -> Value) -> Task<Void, Never> {
^~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:25:26: error: cannot find 'withUnsafeThrowingContinuation' in scope
return try await withUnsafeThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./ModernSwiftConcurrency/00-book-server/.build/checkouts/swift-nio/Sources/NIOCore/AsyncAwaitSupport+OldXcodes.swift:43:26: error: cannot find 'withCheckedThrowingContinuation' in scope
return try await withCheckedThrowingContinuation { cont in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1043/1044] Compiling NIOCore ByteBuffer-lengthPrefix.swift
error: fatalError
The output of swift --version
:
swift-driver version: 1.26.9 Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)
Target: x86_64-apple-macosx12.0
I’m a little confused myself to be honest, since you have macOS 12 SwiftNIO should be compiling just fine…
What I notice is that the backwards compatibility of the Concurrency module was introduced in Swift 5.5.2 and you have 5.5 so that might be hitting some edge case in the conditional compilations in SwiftNIO.
Have you tried installing the latest Xcode?
So yes I installed the latest Xcode but my command-line tools were pointing to Xcode 13.0, not Xcode 13.2.1, and changing that fixed it for me. Changed it under Xcode → Preferences → Locations. Thanks for your help!
you’re welcome, this really ought to be an issue on NIO’s side where an if isn’t checking for 5.5.2 but 5.5
I am getting this error when trying to run swift run:
Merging module COperatingSystemerror: error reading dependency file ‘/Users/NN/Desktop/Async:Await/ray async:await/00-book-server/.build/x86_64-apple-macosx/debug/COperatingSystem.build/Exports.d’: unexpected character in prerequisites
I have Xcode 13.1 and running macOS Monterey 12.2.1
I’m gonna go on a limb here and guess that the error message saying “unexpected character in prerequisites” is about those colons in the folder names. Can you check out the repo is a folder with a simpler name like “swiftconcurrrency” and try again?
I had a “fatal error: could not build module ‘Darwin’ book server” error.
This set of commands resolved my error.
Cheers!
This error means there is a problem on the server side. A server error can be caused by any number of things from uploading the incorrect file to as bug in a piece of code. This error response is a generic “catch-all” response.
Tips to Fix the Server Error
Backing Up Your Site
Clear your browser cookies and cache
Reload or Refresh the Webpage
Greeting,
Rachel Gomez
I had a lot of errors:
/Users/alex/Desktop/concurrency_files/00-book-server/.build/checkouts/vapor/Sources/Vapor/HTTP/Headers/HTTPHeaders+Directive.swift:230:14: error: ambiguous use of ‘split(separator:maxSplits:omittingEmptySubsequences:)’
self.lazy.split(separator: “\”).reduce(into: “”) { (result, part) in
^
Swift.Sequence:2:40: note: found this candidate
@inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) → [ArraySlice<Self.Element>]
^
Swift.Collection:2:40: note: found this candidate
@inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) → [Self.SubSequence]
^
/Users/alex/Desktop/concurrency_files/00-book-server/.build/checkouts/vapor/Sources/Vapor/HTTP/Headers/HTTPHeaders+Directive.swift:230:14: error: ambiguous use of ‘split(separator:maxSplits:omittingEmptySubsequences:)’
self.lazy.split(separator: “\”).reduce(into: “”) { (result, part) in
^
Swift.Sequence:2:40: note: found this candidate
@inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) → [ArraySlice<Self.Element>]
^
Swift.Collection:2:40: note: found this candidate
@inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) → [Self.SubSequence]
^
/Users/alex/Desktop/concurrency_files/00-book-server/.build/checkouts/vapor/Sources/Vapor/HTTP/Headers/HTTPHeaders+Directive.swift:230:14: error: ambiguous use of ‘split(separator:maxSplits:omittingEmptySubsequences:)’
self.lazy.split(separator: “\”).reduce(into: “”) { (result, part) in
^
Swift.Sequence:2:40: note: found this candidate
@inlinable public __consuming func split(separator: Self.Element, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) → [ArraySlice<Self.Element>]
^
Swift.Collection:2:40: note: found this candidate
and so on
XCode Version 14.0.1 (14A400),
swift-driver version: 1.62.8 Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
Target: x86_64-apple-macosx12.0
I’m running macOS 13 with Xcode 14.1 here and the server builds and runs for me. Can you make sure you have an up to date version of the code from GitHub - kodecocodes/mcon-materials: The projects and materials that accompany the Modern Concurrency in Swift book please?
I downloaded latest version of the code from Github and “Yes”. It’s perfectly working.
Thanks for help.
When I try “swift run”, I get:
error: terminated(1): /usr/bin/xcrun --sdk macosx --show-sdk-platform-path output:
xcrun: error: unable to lookup item ‘PlatformPath’ from command line tools installation
xcrun: error: unable to lookup item ‘PlatformPath’ in SDK ‘/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk’
For context, I’m running xcode version 14.3, and “swift --version” gives me:
Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Target: arm64-apple-darwin22.5.0
Any idea on solving the “swift run” error? I’m following the serverside swift with vapor book, version 3.
Thanks!
Hi,
I’m getting the following errors after “swift run”:
patvdp@MiniPat 00-book-server % rm -Rf .build
patvdp@MiniPat 00-book-server % swift run
Fetching GitHub - vapor/vapor: 💧 A server-side Swift HTTP web framework. from cache
warning: ‘vapor’: skipping cache due to an error: Couldn’t fetch updates from remote repositories:
Unknown option: -C
usage: git [–version] [–help] [-c name=value]
[–exec-path[=]] [–html-path] [–man-path] [–info-path]
[-p|–paginate|–no-pager] [–no-replace-objects] [–bare]
[–git-dir=] [–work-tree=] [–namespace=]
[]
Fetched GitHub - vapor/vapor: 💧 A server-side Swift HTTP web framework. (19.51s)
error: Couldn’t get the list of tags:
Unknown option: -C
usage: git [–version] [–help] [-c name=value]
[–exec-path[=]] [–html-path] [–man-path] [–info-path]
[-p|–paginate|–no-pager] [–no-replace-objects] [–bare]
[–git-dir=] [–work-tree=] [–namespace=]
[]
I’m running Ventura 13.5, Xcode 14.3.1.
Swift version:
swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
How can I fix this?
Thanks, Patrick
Hi Akin! there’s an answer in StackOverflow
it suggests trying this command to restore the correct path to the SDK:
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Why these dependencies are there to read the book? Frustrating with error “fatalError”.
Hello,
I just started reading the book and trying to run the server.
I get these errors:
/Users/nsd/Desktop/mcon-materials/00-book-server/.build/checkouts/vapor/Sources/Vapor/HTTP/Server/HTTPServer.swift:380:54: error: reference to captured var 'application' in concurrently-executing code
application: application!,
^
/Users/nsd/Desktop/mcon-materials/00-book-server/.build/checkouts/vapor/Sources/Vapor/HTTP/Server/HTTPServer.swift:388:46: error: reference to captured var 'application' in concurrently-executing code
application: application!,
^
M1 Pro
macOS 14.2.1
Xcode 15.2
swift --version:
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0