We’ve been encountering build failures when switching Git branches in Xcode (15 & 16), where the project fails to build due to missing symbols. Typically, running an Xcode clean resolves the issue, but this is disruptive—especially on large projects where a full rebuild after cleaning can be time-consuming.
We’ve managed to reproduce this issue in a minimal setup:
- Create a new Xcode project.
- Include a local Swift Package in the project. The main project depends on the package.
- Add a new Objective-C class to the package.
- Use that new class in the main project.
- Build (FAILS).
- Clean the project.
- Build (SUCCEEDS).
This issue tends to arise when switching Git branches that introduce new files, such as Objective-C files that don’t exist on the main branch. If a new file is introduced in a feature branch, switching between main and feature requires a clean before the project will build successfully again.
We plan to file a feedback report, but in the meantime, we’re wondering if anyone has found effective workarounds for this problem when switching branches.
The only reasonable work-around we have found is to create an umbrella header manually and include the new header. It would be nice to not have to resort to maintaining umbrella headers in packages but this is ok.