I have a project that includes a
node_modules directory in the root package directory. This directory, like most
node_modules directories is quite large (122MB across 17k files and directories).
When I open this package in Xcode directly (running
xed . from package root), this directory seems to be causing some undesirable behavior:
- Xcode takes noticeably longer to open the project.
- XCBBuildService runs at 100% CPU for about a minute when opening a package for the first time on my MacBook Pro, which makes me thing that this is Xcode indexing the contents of
- "Find in Package" (⇧⌘F) search must be scoped to
Teststo produce meaningful results.
None of these are critical issues, but they are inconvenient. (And I suspect that more developers will start to face this starting in Swift 5.3 because of SE-0271 — especially for projects relating to the web)
Is there any way to exclude certain files or directories from the project Xcode generates for the package?
One workaround that I tried was to run
swift package generate-xcodeproj and remove the folder reference from the project. However, there were a few problems with this approach:
- The generated project has problems linking libxml2 for dependencies that use that library, whereas SPM is able to build the project just fine.
- The project must be regenerated (and subsequently re-edited) whenever a dependency is added or removed.
- The generated project isn't as convenient as the interface Xcode provides when opening a package directly.