migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.07k stars 70 forks source link

Unable to Create Swift GDExtension on Windows #508

Closed atlasapplications closed 1 month ago

atlasapplications commented 1 month ago

OS: Windows 11 Swift: 5.10.1

Overview Using the documentation, I recreated the example project but with Windows and I'm unable to get a working GDExtension for Swift. Everything compiles correctly and the binaries are produced as expected but when I put them in the bin folder Godot produces an error that states "Can't open dynamic library:...." "Error 126: The specified module could not be found."

Expected behavior There should be a Node that simply prints "Hello World from Swift."

Minimal Reproduction Sample This project shows my code. swift_example.zip

atlasapplications commented 1 month ago

After more research I've found the solution.

  1. Go to your Swift installation.
  2. The default is C:\Users\[username]\AppData\Local\Programs\Swift
  3. In the folder Runtimes you'll see the version of Swift you have installed. Navigate into that directory until you see bin.
  4. All the .dll files in that directory need to be copy and pasted into the directory of your GDExtension executables which most people make as bin in the Godot project.

I now see in the documentation where it states this but it was not obvious based off the examples, so perhaps this could be mentioned in more places like the posted GitHub example. Also, the path in the documentation states that Swift is in the Program Files folder and the file structure is different so perhaps it's based on an older version of Swift for Windows.

I hope this is helpful for someone that runs into the same issue!

bestwnh commented 1 month ago

This info should add to the readme.

atlasapplications commented 1 month ago

This info should add to the readme.

I agree!

migueldeicaza commented 4 weeks ago

Which document were you reading?

atlasapplications commented 4 weeks ago

Which document were you reading?

Working in VS Code. These are the docs that helped me solve my problem, under the Windows header.

As a suggestion for improving the docs, it states the Swift install path is under C:\Program Files\Swift but for me at least it is under C:\Users\[username]\AppData\Local\Programs\Swift.

I think it may be a reasonable suggestion that this info also be in the README because the tutorial there only works on Mac without this information.