Swift PM, Bundles and Resources

I read the package-manager-resources proposal too.

I think scope of such proposal is too broad to begin. In my opinion SPM should support resources in a very simple way to start. Then a follow-on proposal could refine details later.

Here is my feedback:

Accessing resources via Bundle apis and strings is probably not optimal but it is the way it would work today and also work in other platforms. A follow-on proposal could improve this with type-safe accessors, etc.

About Location of resources in a package

... This could take the form of a special Resources subdirectory under each target directory, but it seems more natural to allow the resource files to be located alongside the source files with which they are most closely associated.
This would allow grouping of package resources in the same way as sources are grouped, by just creating a directory structure under the individual target subdirectories.
This approach is, for example, common in Xcode projects today.

The main idea of the proposal seems to support resources everywhere (not just in a specific Resources folder). I think is it OK. I just would like to know what would happen with Border.png in below example?

Additionally from allowing resources everywhere, I think still having a special folder Resources inside Source folder could be useful. Everything inside Resources folder would be copied as is, maintaining its folder structure intact, This would be helpful for localization (Folders like en, es, ja, etc containing more resources, etc), for assets folder (Folders with a particular json file and images, data files, etc), etc

Package
 └  Sources
    ├ MyInfoPanel
    │  ├ InfoPanelController.swift
    │  └ Border.png // Collision with Border.png inside IconWidget ?
    ├ IconWidget
    │  ├ IconDataSource.swift
    │  └ Border.png // Collision with Border.png inside MyInfoPanel ?
    └ Resources
       ├ MyInfoPanel
       │ └ Image.png // This would be referenced via "MyInfoPanel/Image.png" ?
       ├ IconWidget
       │ └ Image.png // This would be referenced via "IconWidget/Image.png" ?
       └ Image.png // This would be referenced via "Image.png" ?

I hope we can have SPM supporting resources sometime soon
(not perfect but working if much better than not working at all)

Cheers.

2 Likes