Which path separators are recommended in SwiftPM manifests?

I have a test target which looks like this:

MyTestTarget/
  SomeTests/
    Fixtures/
      A.txt
      B.txt

In my package manifest, I have to specify the resources as a relative path with more than one component:

resources: [.copy("SomeTests/Fixtures")]

Will this work on Windows, too?

I don't see anything in SE-0271. I guess it would work like other SwiftPM paths, but I'm not sure that SwiftPM manifests were designed to include a portable path specification, so I don't think that's really defined anywhere (or is it?)

So should developers just embrace that and use POSIX-style paths everywhere without worrying about Windows compatibility? Will SwiftPM on other platforms (e.g. Windows) work with that model?

CC @compnerd

Yes, for SPM manifests, you can use the / separator - we convert the paths within SPM. The use of parent path references (../SomeTests/Fixtures) are the only concern (before 5.8). If there are places that you run into issues, please file an issue on SPM.

Pedantic note:
There are limitations if you do this of course (nothing outside the current drive can be referenced, nothing on UNC shares, etc).

1 Like