When running "swift build" in command prompt inside my file directory I receive the following error:
Yes, I have followed the install instructions correctly and everything is fresh with no duplicates.
File name is: "Package.swift"
Here is the command prompt logs: (same for developer and normal)
I recommend initialising a new project with
swift package init --type executable. That will create a valid Package.swift.
This is the source of the error,
Package.swift is not supposed to contain the source code for your package.
Package.swift is a package manifest that specifies what dependencies, products, and targets your package declares.
print("hello") code to a file with any other name and then you can compile it as a standalone source file with
swiftc, or with
swift build as a part of a package that has a valid
This is all it does when I run swiftc swift.swift
This is all that returns when I try to build a properly installed swift package.
A new swift package created via the command, or something you downloaded?
Created with the command.
kernel32.lib is provided by the Windows SDK, it sounds like you didn't install Visual Studio properly (this is already covered in the installation instructions) or you have multiple versions installed, in which case you need to use the Developer Command prompt for the Visual Studio version that you want to use.
Thank you I will try this later and keep you updated.
I think the problem here is that SwiftPM isn't reading anything from your manifest file. I.e. it thinks the file is empty.
When I tried to reproduce the two errors from your first screenshot, I got only the second error and a "hello":
The missing "hello" line from your output indicates that SwiftPM didn't read your
print("hello"). Since standard library functions are allowed in the manifest, if the call is read, then "hello" should be in your output.
The first error message says that SwiftPM can't find your tools version specification, even though we can see it's there and well-formed. The specification parser's logic shouldn't be affected by the platform it runs on, and there are some really really extensive test cases just for parsing this line of comment, so I'm very confident that the error is not from the parser. (A bit of an aside: this makes me realise we probably should add some diagnostics for invisible characters, so we can point them out in the error message if they exist.)
So, basically all clues point to that the manifest isn't read by SwiftPM. Either there is a bug in the manifest loader or some calls to system APIs for reading the manifest are not working.
Also note: you will still have an "invalid manifest" error after this problem is resolved, because you don't have a
Package instance named
package in the manifest. We should improve the message here a bit to point out exactly what's causing the error (whether SwiftPM thinks it's empty or
package is missing etc).
Wow thanks a lot I will definitely touch up on the documentation. I think another issue might be that the VS build tools were not installed. Will test again today.