Context
We have a very large codebase in our company 600k+ Lines of Code. The setup is a XcodeProj using Swift Package Manager as the only and main package management tool. We have started a long journey of modularizing our monolithic code by moving features or modules into separate local Swift Packages. The setup we have is an explicit local Swift package for the Contract
, Implementation
, and Mock
.
We have a total of 194 Contract packages, eqaully as many Implementation Packages, and <= 194 Mock packages. A total of almost 582 local Swift Packages.
In our POC phase, we found that creating an explicit package per Category was the best way to maintain our packages because using a single Package with multiple targets created some ambiguous compile messages. We found ourselves having to manaully build each package individually to find out what might have went wrong.
Problem
Currently, as we add more packages and link them to the main XcodeProj Unit Test Target
, we get an XcodeBuild crash. Specifically, we see the following XCBCore MacroEvaluationProgram.executeInContext
. Full crash log can be found here.
Xcode shows the following errors:
Showing All Messages
unexpected service error: The Xcode build system has crashed. Build again to continue.
Internal inconsistency error: never received task ended message for task ID '3' with rule info 'CreateBuildDescription'. Build again to continue.
The surprising thing is that, the main project continues to build and run on a simulator and device. Only the Unit Test Target crashes while building. Additionally, this crash was happening on Xcode 15.2, and Xcode 15.3 right now as well.
We have tried cleaning up our UnitTest Target, removing packages, and checking build configuration to update it with the latest configurations. This has temporary resolved our problem (especially removing the packages linked); however, we seem to be hitting the limit of number of packages again. We have tried debugging, finding different solutions, and finding documentation, but there seems nothing out there regarding a limit of number of packages that could be linked or any similar crashes with XCBCore on the line 0x102a4d634 MacroEvaluationProgram.executeInContext(_:withResultBuilder:alwaysEvalAsString:) + 1220
. Looking at the crash log, it seems like XCBCore is stuck in a recursive loop on that line finally crashing later on.
Any tips, directions, documentation, or build setting change that can overcome this problem would be appreciated.
Our possible next steps as solutions are the following:
- Move the monolith completely to a Swift Package, and link everything to that package, and link that final one package to the XcodeProj.
- Try to revert the usage of multiple separate packages per category, and create one SwiftPackage with multiple targets. This should reduce the number of packages
However, as you can imagine this is a very large amount of work, and it would be blocking us from shipping and running our pipelines for a significant amount of time. That is why, I'm reaching out here to see if anyone in the community maybe has a lead on what could be the root cause and solution.