Update to swift package init templates

Thanks Joe.

The costs of the current directory structure when created on day-one via a template is added complexity right from the beginning. Then to see any code file, even if you only have one or two, you will be opening two folders deep in your IDE, Finder, Terminal, etc. Some people work in a way where that isn't bothersome, especially existing Swift expert users, but others find that heavy.

Explaining the reason why code is two folders deep can also be tricky for newcomers learning the language. Going through educational content for other languages doesn't often expose "code for each target" organization (Java being an obvious exception.)

Curious, what is your feeling about the following approaches, original first:


... vs. targets at the root:

/Target1_previews/.   (etc...)

.. a more generic variant:


Each of these options set you up for multiple targets. The last two only need one nested level, and aren't as obviously "organization by target" for the newcomer to worry about. The last one, IMO, is more clear about code for different purposes, not necessarily multiple creations (which feels more "pro" than a newcomer wants). Note that the templates' Package.swift file is explicit about the folder and target relationship, so are fairly easy to expand to add another, e.g.:

            name: "tests",
            path: "Sources"),

Again, appreciate the discussion!

1 Like