Fix: Static ObjC xcframeworks missing from search paths after binary caching
Context
A user reported a bug (https://github.com/Alex-Ozun/TuistTestCaching): after tuist cache App and then tuist generate --cache-profile all-possible, the build fails with Unable to find module dependency: 'GoogleMaps'.
After caching, FeatureA becomes a cached dynamic xcframework. The graph becomes:
App (target) -> FeatureA.xcframework (dynamic) -> GoogleMaps.xcframework (static, ObjC)
The StaticXCFrameworkModuleMapGraphMapper is designed to handle exactly this scenario (static ObjC xcframeworks behind dynamic xcframeworks) by adding FRAMEWORK_SEARCH_PATHS, HEADER_SEARCH_PATHS, and module map flags. However, it bails out early at line 32-33 when no Package.swift is found, which is the case for Tuist-native projects using Project.swift.
Root Cause
In cli/Sources/TuistKit/Mappers/Graph/StaticXCFrameworkModuleMapGraphMapper.swift line 32-33:
The mapper needs a derivedDirectory to place generated module maps and umbrella headers. It computes this from Package.swift's location. For non-SPM projects, Package.swift doesn't exist and the mapper does nothing, leaving the consuming target without the necessary search paths to find GoogleMaps's module.
Fix
1. Modify StaticXCFrameworkModuleMapGraphMapper.map() to use a fallback derived directory
Change lines 32-41 from returning early to computing a fallback path. When Package.swift is absent, use {graph.path}/Tuist/.build/tuist-derived/ which mirrors the SPM convention and sits within the existing Tuist/ directory that Tuist-native projects always have.
This is a minimal, targeted change. Everything else in the mapper (module map generation, FRAMEWORK_SEARCH_PATHS, HEADER_SEARCH_PATHS, $(SRCROOT)-relative path calculation) works identically regardless of how derivedDirectory was computed.
Add two new test cases that mock locatePackageManifest to return nil, mirroring the existing tests at line 33 and 166:
test_map_when_static_xcframework_library_linked_via_dynamic_xcframework_without_package_manifest - library-based (.a) xcframework without Package.swift, verifies module map side effects and build settings use {graph.path}/Tuist/.build/tuist-derived/
test_map_when_static_xcframework_framework_linked_via_dynamic_xcframework_without_package_manifest - framework-based (.framework) xcframework without Package.swift, verifies FRAMEWORK_SEARCH_PATHS is set
These mirror the existing tests at lines 33-164 and 166-256 but with manifestFilesLocator returning nil.
Verification
Run the new tests:
code
xcodebuild test -workspace Tuist.xcworkspace -scheme Tuist-Workspace \
-only-testing TuistKitTests/StaticXCFrameworkModuleMapGraphMapperTests
Run all existing mapper tests to verify no regressions:
code
xcodebuild test -workspace Tuist.xcworkspace -scheme Tuist-Workspace \
-only-testing TuistKitTests/StaticXCFrameworkModuleMapGraphMapperTests
End-to-end: clone the reproduction repo, run tuist cache App, then tuist generate --cache-profile all-possible, then xcodebuild build and verify it succeeds.
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/pepicrft/.REDACTED.jsonl
Assistant
I'll start by reading the source file and test file to understand the current implementation before making changes.
Assistant
Now let me check the Constants to understand the constant names used.
Assistant
Good. Now I have all the context needed. Let me implement both changes.
Assistant
Now let me add the two new test cases. I'll add them right before the test_map_when_static_xcframework_linked_via_static_xcframework test (at line 1053).
Assistant
Now let me verify the source file looks correct and then run the tests.
Assistant
The source change looks correct. Now let me run the tests.
Assistant
There's a signing issue. Let me try a different approach, using the test destination for a simulator or specifying the correct settings.
Assistant
All 13 tests passed, including the 2 new ones and all 11 existing tests.
Replaced the early return when Package.swift is not found (lines 32-33) with a fallback that computes derivedDirectory as {graph.path}/Tuist/.build/tuist-derived/. This matches the SPM convention and allows the mapper to work for Tuist-native projects that use Project.swift instead of Package.swift.
Test additions (cli/Tests/TuistKitTests/Mappers/Graph/StaticXCFrameworkModuleMapGraphMapperTests.swift):
test_map_when_static_xcframework_library_linked_via_dynamic_xcframework_without_package_manifest - verifies library-based (.a) static xcframeworks produce correct module map side effects and build settings when no Package.swift exists
test_map_when_static_xcframework_framework_linked_via_dynamic_xcframework_without_package_manifest - verifies framework-based (.framework) static xcframeworks produce correct FRAMEWORK_SEARCH_PATHS when no Package.swift exists
All 13 tests pass (11 existing + 2 new).
User
Did you test if it works with the fixture shared?
Assistant
No, I didn't test with the reproduction repo from the issue. Let me look at it and see if there's a fixture in this repo that covers this scenario, or if I should try the external reproduction.
Assistant
There's an existing acceptance test that covers a similar scenario. Let me look at it more closely and also check the reproduction repo from the issue.
Assistant
This acceptance test uses SVProgressHUD (an ObjC static framework with resources), but the structure is App -> SVProgressHUD (static xcframework with resources). The bug we're fixing is specifically about App -> DynamicFramework.xcframework -> StaticObjC.xcframework where the StaticXCFrameworkModuleMapGraphMapper bails out because there's no Package.swift.
The existing acceptance test uses install (SPM dependencies), so Package.swift exists. The reproduction repo from the issue is a better test. Let me check it.
Assistant
This repo uses the released version of Tuist. To test with our local changes, I need to build the CLI from source and use it against this fixture. Let me do that.
Assistant
Good. Now let me test with the reproduction repo.
Assistant
The project builds without caching. Now let me cache FeatureA and regenerate to reproduce the original bug scenario.
Assistant
FeatureA is cached. Now regenerate and build - this is the step that should fail without the fix.
Assistant
Hmm, it says "Using cache binaries for the following targets:" but doesn't list anything. Let me check if the cache was actually used.
Assistant
It still generated FeatureA as a project (not cached). The caching step said it stored 1 target, but generate didn't pick it up. This is likely because tuist cache needs to be invoked differently, or the generate command needs a flag. Let me check the README.
Assistant
Interesting - it says "Using cache binaries for the following targets:" but the list is empty, and it's still building FeatureA from source (compiling FeatureA.swift). The cache isn't being used. Let me check if there's a Tuist/ directory or configuration needed.
Assistant
There's no Tuist/ directory at all. The cache stored the binary somewhere but the generate/build step isn't using it. Let me check where the cache stores things and look at how cache binaries get picked up.
Assistant
The cache exists. The issue is that tuist build is not picking it up. Let me look at how the generate command determines which targets to use from cache. It might be related to the hashing. Let me try with --verbose.
Assistant
I see - it says "Using cache profile onlyExternal" which means the default is to only cache external SPM dependencies. The tuist cache App stored FeatureA, but tuist generate uses the onlyExternal profile by default. The reproduction README says to use tuist build App (not tuist generate). Let me look at how tuist build handles cache differently, or perhaps there's a flag.
Assistant
Now FeatureA is being used from cache. Let me build.
Assistant
The build fails. Let me see the actual error.
Assistant
This is a linker error about x86_64 architecture, not the module resolution error from the bug report. This seems to be an architecture mismatch issue with the GoogleMaps xcframeworks in the repo (they may not have the right slices). Let me check if there are the right architectures.
Assistant
The build succeeds with our fix. The previous x86_64 failure was just an architecture mismatch (the GoogleMaps xcframework in the repo doesn't have x86_64 simulator slices), not related to our fix.
Let me now verify this was indeed failing before the fix by reverting the change temporarily.
Assistant
The bug is confirmed. Without the fix: Unable to find module dependency: 'GoogleMaps'. With the fix: BUILD SUCCEEDED.
Let me restore the fix.
Assistant
Let me also clean up the temporary build directories.
Assistant
Verified end-to-end with the reproduction repo:
Without the fix: error: Unable to find module dependency: 'GoogleMaps' (BUILD FAILED)
With the fix: BUILD SUCCEEDED
The fix works correctly. The StaticXCFrameworkModuleMapGraphMapper was returning early when no Package.swift was found, skipping the generation of FRAMEWORK_SEARCH_PATHS, HEADER_SEARCH_PATHS, and module map flags needed for static ObjC xcframeworks behind dynamic xcframeworks. The fallback derivedDirectory at {graph.path}/Tuist/.build/tuist-derived/ allows the mapper to work for Tuist-native projects.
User
Can you create a PR with the fix?
Assistant
Let me first check the current state and recent commits to prepare the PR.
Assistant
The Package.resolved change is unrelated. I'll only commit the two relevant files.
Help me understand why thi sis happening. Is this a recent issue?
Assistant
Good question. Let me trace the history to understand when this started happening.
Assistant
The monorepo step moved it. Let me check the original file before the monorepo move.
Assistant
The file was introduced in eb0c8eede3. Let me check that original commit to see if the Package.swift guard was there from the start.
Assistant
So the guard on Package.swift was there from day one (September 2024). This mapper was originally written specifically for the SPM integration use case, where Tuist resolves Swift packages and places derived files relative to Package.swift. The scenario of Tuist-native projects with cached targets wasn't considered at that time.
Let me check the PR that introduced the mapper for more context.
Assistant
Now let me check if there was a fixture app_with_google_maps that was used for testing, and whether it had a Package.swift.
Assistant
That confirms it. The original fixture (app_with_google_maps) uses Tuist/Package.swift to pull GoogleMaps as an SPM dependency. The mapper was designed and tested only for that flow.
The reproduction repo from the issue uses a different approach: GoogleMaps xcframeworks are vendored directly in the project (via .xcframework(path:) in Project.swift), with no Package.swift at all. This is a perfectly valid Tuist-native setup, but the mapper never handled it.
Here's the timeline:
September 2024 (eb0c8eede3): The StaticXCFrameworkModuleMapGraphMapper was introduced to fix static ObjC xcframeworks linked through dynamic xcframeworks. It was designed for the SPM integration path where Package.swift exists, and computes the derived directory relative to it. The guard on Package.swift was there from the start.
Since then: Several fixes were made to this mapper (path calculation, deduplication, framework search paths), but they all kept the same assumption that Package.swift exists.
The bug: This was never a regression. It simply never worked for Tuist-native projects that vendor xcframeworks directly without SPM. The scenario only surfaces after caching (when FeatureA becomes a dynamic xcframework and its static ObjC dependency GoogleMaps needs the search path fixup), which is why it wasn't caught earlier. Most users hitting this pattern were using SPM to pull GoogleMaps, where Package.swift exists and the mapper works fine.
User
Can you include this context in the PR description?
Assistant
PR description updated. Let me check the CI failure.
Assistant
Let me check the Lint and Linux failures.
Assistant
These lint warnings are all pre-existing (not from my changes). Let me check if the lint failure is actually about formatting.
Assistant
There it is. The lint error is from my change:
code
StaticXCFrameworkModuleMapGraphMapper.swift:28:17: error: Function Body Length Violation: Function body should span 100 lines or less excluding comments and whitespace: currently spans 104 lines (function_body_length)
The map() function is now 104 lines (limit is 100). I need to extract part of the logic. Let me also check the Linux failures.
Assistant
The Linux failures are unrelated (server error 500 from the Tuist registry). The only failure caused by my change is the lint error. Let me fix it by extracting the derived directory computation into a private method.
Assistant
I'll extract the derived directory computation into a private method.
Assistant
Now add the private method. I'll put it right after the moduleMapFlag method.
Assistant
Pushed. The lint error was that the map() function exceeded the 100-line limit (104 lines). I extracted the derived directory computation into a private derivedDirectory(for:) method, which brings it back under the limit.
The other CI failures (Linux Build and Linux Unit Tests) are unrelated -- they're hitting a server error 500 from the Tuist package registry when resolving dependencies.
User
Can you monitor CI?
Assistant
Lint is passing now. The Linux failures are still there -- let me confirm they're the same registry error.
Assistant
Same issue -- Tuist registry is having problems. Completely unrelated to our changes. Let me wait for the remaining macOS jobs to finish.
Assistant
Several acceptance tests are still pending. Let me wait a bit more.
Assistant
The macOS "Acceptance Tests" job also failed. Let me check that one.
Assistant
Interesting -- every test suite reports "Executed 0 tests", yet the overall result is TEST FAILED. This looks like the tests couldn't even be discovered/run. Let me check more of the log.
Assistant
This is TuistCacheEEAcceptanceTests which reports 0 tests executed across all iterations. This seems like a flaky infrastructure issue (possibly the tests need a server connection or some EE feature). Let me verify this same job fails on main too.
Assistant
The CLI Cache EE workflow also failed on main (id: 21955384509). Let me check what the failure was there.
Assistant
Same pattern -- the Acceptance Tests job fails on main too. This is a pre-existing flaky/broken test, not caused by our changes.
All failures are pre-existing and unrelated to our changes. The jobs that actually exercise our code (Unit Tests, Lint, SwiftPM Build) all pass.
User
Fix those acceptance tests, and investigate the issues to see if you can fix them
Assistant
Let me investigate each failure in detail.
Assistant
0 tests executed in 11 iterations. The test target is building but no tests are being discovered. Let me get more context from the logs.
Assistant
The TuistCacheEE submodule is being checked out. The tests compile but 0 tests are discovered. This is a private submodule issue. Let me look at the Linux failures more carefully to understand if there's anything fixable.
Assistant
The Linux Unit Tests failure is a linker error -- an undefined reference to a symbol from TuistSupport. This is also a pre-existing issue (not related to our change).
Let me now look more carefully at the Acceptance Tests failure. The key question is why 0 tests are discovered in TuistCacheEEAcceptanceTests.
Assistant
The tests compile and link fine but 0 are discovered. Let me look at the test file.
Assistant
The submodule only has Sources, no Tests. Let me find the acceptance tests.
Assistant
These tests use Swift Testing (@Test) not XCTest. The CI output shows "Executed 0 tests" which is XCUnit's output. The tests are using Swift Testing but the runner seems to expect XCTest. Let me check the xcodebuild command more carefully and the CI workflow.
Assistant
So the actual xcodebuild command that runs has -test-iterations 2 and uses -retry-tests-on-failure. It reports 0 tests in 11 iterations (the Swift Testing tests are compiled but not discovered as XCTest tests). The test runner considers "0 tests executed" as a failure with exit code 65.
This is a test discovery problem. The tests use Swift Testing @Test macros and struct (not XCTestCase). Let me check if there's a configuration issue -- maybe the scheme needs to enable Swift Testing.
Let me check the CI workflow to understand what's going on.
Assistant
The test is run with tuist test TuistCacheEEAcceptanceTests. The submodule checkout uses submodules: recursive, but earlier I saw "Skipping submodule 'cli/TuistCacheEE'" followed by it being cloned later. Let me check the cli:ee task to understand the submodule init.
Assistant
OK now I understand the overall setup. The 0 tests issue is interesting. These tests use Swift Testing, but the CI runner reports 0 tests. Let me look at how tuist test invokes xcodebuild and whether Swift Testing tests are supported.
The key insight is: these tests use @Test (Swift Testing) not XCTestCase. Let me check the xcodebuild output more carefully to see if Swift Testing tests are being counted separately.
Assistant
The Swift Testing tests ARE running and passing. The "Executed 0 tests" is just the XCTest output (0 XCTest tests, which is expected since these are all Swift Testing tests). But xcodebuild considers this a failure.
Let me see the actual failure.
Assistant
I see the pattern now. TuistCacheEECanaryAcceptanceTests suite starts but never finishes -- no pass/fail reported for it. It starts, then after ~34 seconds a new test run starts. This keeps happening repeatedly. The canary tests use .withFixtureConnectedToCanary(...) which requires connecting to a canary server. The tests are probably timing out trying to connect.
Let me check the withFixtureConnectedToCanary trait to understand.
Assistant
Now I understand. The canary tests require TUIST_AUTH_EMAIL and TUIST_AUTH_PASSWORD env vars (line 33-34), and they connect to a canary server. The test starts, tries to #require the env variable, and when it's not available (e.g. in a PR from a non-member), the test just gets skipped silently with Swift Testing. But something is causing the suite to never complete.
Let me look at the actual main branch failure to confirm it's the same pattern.
Assistant
Exact same pattern on main. The TuistCacheEECanaryAcceptanceTests suite starts but never completes -- it keeps restarting every ~34 seconds. The tests are silently failing (probably timing out connecting to the canary server) and the -retry-tests-on-failure -test-iterations 2 causes them to retry endlessly until the job times out or xcodebuild gives up.
The issue is that the canary tests are crashing or hanging during the fixture setup (trying to connect to the canary server, login, create org/project). When the test crashes, xcodebuild restarts it as a retry. Since each canary test never completes, xcodebuild keeps retrying all of them.
Let me verify by checking how many times the canary suite restarts.
Assistant
8 restarts for the canary suite. The non-canary tests (TuistCacheEEAcceptanceTests) pass fine. None of this is related to our PR change -- it's a pre-existing issue with the canary tests on CI. Since I can't reproduce or debug the canary server connectivity from here, and this is entirely unrelated to the static xcframework fix, there's nothing actionable I can do here.
Here's the full picture:
Failure
Root cause
Related to our PR?
Fixable by us?
Lint
map() exceeded 100-line limit
Yes
Fixed (extracted derivedDirectory method)
Acceptance Tests
TuistCacheEECanaryAcceptanceTests hang connecting to canary server, causing infinite retries
No
No -- requires canary server investigation
Linux Build
Tuist registry returning 500/timeout when resolving Komondor
No
No -- server-side issue
Linux Unit Tests
Linker error: undefined symbol from TuistSupport on Linux
No
No -- pre-existing Linux build issue
All three non-lint failures reproduce identically on main and are pre-existing infrastructure/server issues. Our PR only introduced the lint issue, which is already fixed.