AsyncExtensions icon indicating copy to clipboard operation
AsyncExtensions copied to clipboard

Avoid sharing schemes with library users

Open davdroman opened this issue 3 years ago • 4 comments

Description

When consuming this library as a dependency in my project, I noticed Xcode autogenerated a scheme for the library among my local schemes, which is not desirable behavior.

As a workaround, this PR gitignores .swiftpm altogether and introduces an xcworkspace as a scheme container that disallows SPM from leaking schemes onto consumers.

Libraries as big as TCA use this approach to effectively hide away all its schemes (and subdependency schemes) from users.

Checklist

  • [x] this PR is based on the main branch and is up-to-date, if not please rebase your branch on the top of main
  • [x] the commits inside this PR have explicit commit messages
  • [x] ~~unit tests cover the new feature or the bug fix~~
  • [x] ~~the feature is documented in the README.md if it makes sense~~
  • [ ] the CHANGELOG is up-to-date

davdroman avatar Nov 01 '22 13:11 davdroman

Thanks for the PR. I'll review it ASAP

twittemb avatar Nov 09 '22 14:11 twittemb

Hi,

I’ve just learned about @_implementationOnly. I think it allows to hide the internal deps from the consumer. Perhaps it could address the issue you’re describing?

Have you already used such a statement?

twittemb avatar Nov 17 '22 01:11 twittemb

AFAIK that only helps ensure that internal modules aren't visible to consumers, but schemes are still exported because they're included in the .swiftpm folder so Xcode sees them regardless of module visibility.

Ref: https://forums.swift.org/t/preventing-spm-packages-dependencies-from-being-exported-when-importing-the-package/43660

davdroman avatar Nov 17 '22 16:11 davdroman

This is a nice addition! Without this Xcode selects AsyncExtension as active scheme because it starts with "A" instead of my host SPM project Foo which has a dependency on AsyncExtension. The effect of this is when I open Xcode and press CMD U to test, Xcode tries to test AsyncExtension which fails.

Sajjon avatar Jan 08 '23 07:01 Sajjon