Prepare-Packages build phase not always run in other projects
I've got the package to build, (very annoying google don't put their artifacts in releases for swiftpm! - side note; stealing the dylib from one of their CI runs does seem to work) - putting dylib, pkconfig etc in their right place, and the demos in your package's/this repository run fine.
I then try and add the same package (via local package so it's got all my changes etc), it then doesn't build
... build target WebGPU (from the package)
/Volumes/Code/SwiftWebGpu/Sources/WebGPU/Extensions.swift:5:11: error: cannot find type 'Surface' in scope
extension Surface {
^~~~~~~
/Volumes/Code/SwiftWebGpu/Sources/WebGPU/Extensions.swift:6:47: error: cannot find type 'SurfaceTexture' in scope
public func getCurrentTexture() throws -> SurfaceTexture {
^~~~~~~~~~~~~~
/Volumes/Code/SwiftWebGpu/Sources/WebGPU/Extensions.swift:5:11: Cannot find type 'Surface' in scope
/Volumes/Code/SwiftWebGpu/Sources/WebGPU/Extensions.swift:6:47: Cannot find type 'SurfaceTexture' in scope
If I comment out the Surface extension (I've not actually found where Surface comes from yet - is it in your bindings, or has swift pulled this from a modulemap, or C headers??) it then fails to find Instance, Adaptor, Device etc
I've tried adding all the libs that the swift packages uses, but the error I guess is before there, as its during the package target.
Is there any special setup in your project/package here, that might be missing when just using the swift-package from another project?
If you managed to run the demos then that's a promising start. It sounds like it isn't running the code generation plugin in this instance though.
Do you mind sharing the Package.swift in your project, or at least the part where it is linking to swift-webgpu? Are you using Xcode or other?
Intersestingly, creating a completely new project, adding the package from this repository url (with all my prebuilt stuff in /usr/xxx) this compiles and runs (once I've copied the dylib to a path it can find)
Added the libs & the executable when SPM prompts...
Will do a little more investigation as to why it didn't work in my project...
Fresh installation into my app again, (exact same process) comparing build, under Build target WebGPU it doesn't run the step Run custom script Generating WebGPU...
Just working out how to manually add this, and why it doesn't automaticly appear for my project...
This may be a clue
https://forums.swift.org/t/how-can-i-use-a-swift-package-build-plugin-to-process-a-custom-resource/64091/2
To run BuildToolPlugins, your xcode project may need to be a min version (and I had started this project in a previous xcode version...)
Okay, I noticed a build step Prepare Packages (before Prepare build) was missing in my project.
Adding webgpu/build/dawn to my target's dependencies made no effect.
Adding WebGPU as a target to my scheme's build targets, DID instate that Prepare packages step, which runs the generate-webgpu build-tool step/plugin, and now builds.
This is NOT present in my freshly-made project, is not set as a dependency, but somehow it detects it as a dependency.
No other changes required... xcode being xcode perhaps.
Will try continue to try and find a way for xcode/prject/target to realise that this is a build dependency (or why a fresh project does auto set things up)