finnvoor / PlaydateKit

Create games for Playdate using Swift.
https://finnvoor.github.io/PlaydateKit/documentation/playdatekit
Creative Commons Zero v1.0 Universal
190 stars 18 forks source link

Error ```swift package pdc``` on Windows #68

Open TylerJaacks opened 1 month ago

TylerJaacks commented 1 month ago

swift package pdc

error: plugin compilation failed: <PluginCompilationResult(
    succeeded: false,
    commandLine: C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\bin\swiftc.exe -L C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\lib\swift\pm\PluginAPI -lPackagePlugin -sdk C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Platforms\5.10.1\Windows.platform\Developer\SDKs\Windows.sdk -libc MD -I C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Platforms\5.10.1\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows -I C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Platforms\5.10.1\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -L C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Platforms\5.10.1\Windows.platform\Developer\Library\XCTest-development\usr\lib\swift\windows\x86_64 -use-ld=lld -g -swift-version 5 -package-description-version 5.10.0 -I C:\Users\tylerjaacks\AppData\Local\Programs\Swift\Toolchains\5.10.1+Asserts\usr\lib\swift\pm\PluginAPI -parse-as-library -Xfrontend -serialize-diagnostics-path -Xfrontend D:\Desktop\PlaydateKitTemplate\.build\plugins\PDCPlugin\cache\PDCPlugin.dia D:\Desktop\PlaydateKitTemplate\.build\checkouts\PlaydateKit\Plugins\PDCPlugin\PDCPlugin.swift -o D:\Desktop\PlaydateKitTemplate\.build\plugins\PDCPlugin\cache\PDCPlugin.exe,
    executable: D:\Desktop\PlaydateKitTemplate\.build\plugins\PDCPlugin\cache\PDCPlugin.exe
    diagnostics: D:\Desktop\PlaydateKitTemplate\.build\plugins\PDCPlugin\cache\PDCPlugin.dia
    compilerOutput: "error: fatalError
error: emit-module command failed with exit code 1 (use -v to see invocation)
D:\Desktop\PlaydateKitTemplate\.build\checkouts\PlaydateKit\Plugins\PDCPlugin\PDCPlugin.swift:41:64: error: cannot call value of non-function type 'String'
    let home = FileManager.default.homeDirectoryForCurrentUser.path()
                                                               ^   ~~

D:\Desktop\PlaydateKitTemplate\.build\checkouts\PlaydateKit\Plugins\PDCPlugin\PDCPlugin.swift:317:52: error: no exact matches in call to initializer
                  let data = try? Data(contentsOf: URL(filePath: ""\(home)\(toolchainPath)/Info.plist"")),
                                                   ^
Foundation.URL:8:12: note: incorrect labels for candidate (have: '(filePath:)', expected: '(fileURLWithPath:)')
    public init(fileURLWithPath path: String)
           ^
Foundation.URL:2:12: note: incorrect labels for candidate (have: '(filePath:)', expected: '(fileReferenceLiteralResourceName:)')
    public init(fileReferenceLiteralResourceName name: String)
           ^
D:\Desktop\PlaydateKitTemplate\.build\checkouts\PlaydateKit\Plugins\PDCPlugin\PDCPlugin.swift:321:52: error: no exact matches in call to initializer
                  let data = try? Data(contentsOf: URL(filePath: ""/\(toolchainPath)/Info.plist"")),
                                                   ^
Foundation.URL:8:12: note: incorrect labels for candidate (have: '(filePath:)', expected: '(fileURLWithPath:)')
    public init(fileURLWithPath path: String)
           ^
Foundation.URL:2:12: note: incorrect labels for candidate (have: '(filePath:)', expected: '(fileReferenceLiteralResourceName:)')
    public init(fileReferenceLiteralResourceName name: String)
           ^
"
)>
deevus commented 1 month ago

There are more issues than this on Windows. It looks like the build process would only run on MacOS or Linux. Paths are hardcoded based on the *nix Playdate SDK.

On Windows, the Playdate SDK uses CMake, whereas on MacOS/Linux it uses a bundled version of gcc for ARM.

This is not insurmountable, but it goes deeper than the OP's issue.

TylerJaacks commented 1 month ago

So this works on Linux? Cause that is fine I can use WSL.

deevus commented 1 month ago

So this works on Linux? Cause that is fine I can use WSL.

It may, if you have the linux Playdate SDK installed.

deevus commented 1 month ago

It looks like the Linux version of swift also has the same problem that you encountered in the OP.

finnvoor commented 1 month ago

Currently PlaydateKit only supports macOS. It should be fairly easy to get it working on Linux, probably just need to update PDCPlugin to switch out some paths and use swiftc directly instead of xcrun. If I get a Linux env set up I may spend some time trying to get this working soon.

Not entirely sure what's required for Windows support and I'm not planning on looking into this any time soon, but as you said you should be able to use WSL with Linux.