Windows SPM invalidManifestFormat. Am I missing a dependency?

I'm on Windows using Swift 5.6 and the CLion Swift plugin. Whenever I go to create a new package, I get the following failure.

Swift Package dependencies resolution failed with exit code 1:
'helloworld': error: invalidManifestFormat("<module-includes>:1:10: note: in file included from <module-includes>:1:\r\r\n#include \"dispatch.h\"\r\r\n         ^\r\r\nC:\\Library\\Developer\\Platforms\\Windows.platform\\Developer\\SDKs\\Windows.sdk\\usr\\include\\dispatch/dispatch.h:66:10: note: in file included from C:\\Library\\Developer\\Platforms\\Windows.platform\\Developer\\SDKs\\Windows.sdk\\usr\\include\\dispatch/dispatch.h:66:\r\r\n#include <dispatch/time.h>\r\r\n         ^\r\r\nC:\\Library\\Developer\\Platforms\\Windows.platform\\Developer\\SDKs\\Windows.sdk\\usr\\include\\dispatch/time.h:67:9: error: missing \'#include <stdint.h>\'; \'uint64_t\' must be declared before it is used\r\r\ntypedef uint64_t dispatch_time_t;\r\r\n        ^\r\r\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.31.31103\\include\\stdint.h:25:28: note: declaration here is not visible\r\r\ntypedef unsigned long long uint64_t;\r\r\n                           ^\r\r\n<unknown>:0: error: could not build C module \'CDispatch\'\r\r\n<module-includes>:1:10: note: in file included from <module-includes>:1:\r\r\n#include \"DispatchOverlayShims.h\"\r\r\n         ^", diagnosticFile: nil)

Visual Studio is up-to-date and I have the Windows 10 and 11 SDKs installed. I also uninstalled and reinstalled C++ cmake and the MSVC v143 build tools...

I'm a complete Windows noob though. Is someone here able to make more sense of the error I'm getting?

What happens if you run outside of CLion?

BTW I am wondering that your CLion currenctly works at all with Swift, mine (2022.3.3 & 2022.3.4) is trying to update symbols without ever coming to an end.

Good point. Doesn’t appear to be related to CLion. I made a single swift file on the desktop and called

swift ./playground.swift

Got an identical error message to the previous one.

That is expected behaviour. The interpreter has issues that no one has stepped forward to help resolve. Please invoke the compiler and generate an executable instead.

Same thing again I believe, but more readable. Assuming I did it right :sweat_smile:

swiftc -o playground .\playground.swift

<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "dispatch.h"
         ^
C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\dispatch/dispatch.h:66:10: note: in file included from C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\dispatch/dispatch.h:66:
#include <dispatch/time.h>
         ^
C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\include\dispatch/time.h:67:9: error: missing '#include <stdint.h>'; 'uint64_t' must be declared before it is used
typedef uint64_t dispatch_time_t;
        ^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\stdint.h:25:28: note: declaration here is not visible
typedef unsigned long long uint64_t;
                           ^
<unknown>:0: error: could not build C module 'CDispatch'
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "DispatchOverlayShims.h"
         ^

Seems like the modulemaps were not deployed. Did you install Swift after you installed Visual Studio? Do you have more than one copy of Visual Studio installed?

I don't remember when I installed Swift originally. I ended up uninstalling and reinstalling. Right now I have VS Community 2019 and 2022

Okay; does it function properly after reinstalling Swift? Having both VS2019 and VS2022 is a good test case - I wonder if the installer is accidentally not installing modifications to both versions?

If after re-installation, it doesn't work, it would be useful to re-uninstall. Then install again from the command line with maximum logging (IIRC, /Lv*x log.txt is the parameter, /? should show the help info). That should at least give us some visibility into what is going on with the deployment.

I can try that.. So far I've been using the downloadable installer.

Do you mean via winget? I'm not sure about the /Lv*x part but I just ran the following.

 winget install --id Swift.Toolchain --log log.txt

Gist here. If that's not it, could you tell me what I'm typing in lol? Sorry. Thanks for all the help so far.

Sorry, I should've been clearer - the instructions were for the downloadable installer . The downloadable installer itself is a program, which can be invoked with the arguments:

.\installer.exe /Lv*x log.txt

I think that C:\Users\wrrn2\Desktop\log_001_sdk.msi.txt might contain the install logs? I'm not sure if they are preserved.

Oh gotcha. I still have the logs on my desktop. Gist

Thanks, that does help somewhat.

[23332:7396:0318/151026.522:INFO:swift_installer.cc(294)] SDKROOT: C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
[23332:7396:0318/151026.522:INFO:swift_installer.cc(298)] UniversalCRTSdkDir: "C:\\Program Files (x86)\\Windows Kits\\10\\"
[23332:7396:0318/151026.524:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.17763.0\\ucrt\\module.modulemap"
[23332:7396:0318/151026.529:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.17763.0\\um\\module.modulemap"
[23332:7396:0318/151026.529:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\module.modulemap"
[23332:7396:0318/151026.530:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\um\\module.modulemap"
[23332:7396:0318/151026.530:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.20348.0\\ucrt\\module.modulemap"
[23332:7396:0318/151026.531:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.20348.0\\um\\module.modulemap"
[23332:7396:0318/151026.531:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22000.0\\ucrt\\module.modulemap"
[23332:7396:0318/151026.532:INFO:swift_installer.cc(329)] Deployed "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22000.0\\um\\module.modulemap"
[23332:7396:0318/151026.537:INFO:swift_installer.cc(357)] Deployed "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.29.30133\\include\\module.modulemap"
MSI (s) (44:84) [15:10:26:540]: Executing op: End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=0)
[23332:7396:0318/151026.539:INFO:swift_installer.cc(357)] Deployed "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.29.30133\\include\\visualc.apinotes"

It seems that the support files are deployed to the VS2022 install. Are you running swift from the vs2019 command prompt or vs2022? Do you have more than one toolset installed in vs2022?

1 Like

I've been running Swift through powershell 7.2.2. After your comment I tried it in the 2019 and 2022 visual studios to the same effect.

I ended up just removing VS 2019, 2022 and Swift. Then only reinstalled VS 2022 (+ dependencies and some other stuff I use) and Swift and now it works like a charm.

I only got a Windows machine in December and I don't remember necessarily wanting to have two VS installations. I wonder if I started with 2019 and then 2022 got recommended to me at some point by some program or Windows itself.

Interesting; there is no reason that Swift should be unable to co-exist with two Visual Studio installations (or even multiple editions of the same version). I suspect that somehow the toolset that clang selects and the toolset that the installer populated are mismatched.

There is the question that I had about what to do here swift-installer-scripts/swift_installer.cc at main · apple/swift-installer-scripts · GitHub ... but I never did figure out what the best solution here is. I suspect that we want to enumerate all toolsets and just populate the module maps.

Thanks for all the details here, it encourages a particular direction at the very least.

Ok, that makes sense. And I had also assumed that under normal circumstances multiple installations wouldn't be an issue.

Thanks again for all the help!