Adding ObjC Files in Xcode Packages Requires a Clean Build

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:

  1. Create a new Xcode project.
  2. Include a local Swift Package in the project. The main project depends on the package.
  3. Add a new Objective-C class to the package.
  4. Use that new class in the main project.
  5. Build (FAILS).
  6. Clean the project.
  7. 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.

Adding ObjC Files in Xcode Packages Requires a Clean Build
 
 
Q