[Second review] SE-0386: `package` access modifier

my observation having participated extensively in the original review thread, was that median reception to the proposal was mixed to negative.

having watched the steady march of various “package keyword” PRs getting merged into apple/swift over the past month, i was quite concerned that the language workgroup was simply going to ignore all feedback and forge ahead anyway. but i am relieved that the workgroup is taking the need to partition modules within a package seriously, and that the proposal now includes a means for excluding individual targets from the global “package” group. this is a major step forward.

unfortunately, i think that simply excluding individual targets is not enough, we need to be able to add excluded targets to a different, named “package” group, otherwise this feature is effectively unavailable to the second or third, etc. nucleus within a versioned package distribution. and in the short term, this puts pressure on packages to split up into multiple subpackages, which is really really bad, because packages are like countries: once you split them up it’s almost impossible to put them back together again, since now you have stable versioning and module aliasing to think about.

this is already outlined as a “future direction” in the proposal text:

The group setting per target in Swift Package Manager allows a target to opt out of a package boundary, but if there is a need for creating multi-groups within a package, the setting could be expanded to allow that by introducing a .named(GROUP_ID) option, where GROUP_ID is a unique identifier for a specific group the target belongs to.

enum Group {
  case package
  case excluded
  case named(String)

For example, the new option could be specified in a target setting in a manifest like so:

  .target(name: "Game", dependencies: ["Engine"], group: .named("Core"))

i think this is a perfectly sensible design, that would completely fulfill the multinuclear use case, and should (must?) be incorporated into the proposal itself.