Skip to content
Latchkey

Swift "Could not find module 'X' for target" in CI

A binary framework or XCFramework ships a Swift module compiled for some architectures but not the one the runner is building for (often arm64 iOS Simulator on Apple silicon), so the compiler cannot find a usable module slice.

What this error means

The Swift build fails with "Could not find module 'SomeKit' for target 'arm64-apple-ios-simulator'; found: x86_64-apple-ios-simulator" or similar architecture mismatch.

swift
error: Could not find module 'SomeKit' for target 'arm64-apple-ios-simulator';
found: x86_64-apple-ios-simulator, x86_64

Common causes

The framework lacks an arm64 simulator slice

On Apple silicon runners the simulator target is arm64, but the dependency was only built for x86_64 simulator, so no matching module exists.

A fat framework instead of an XCFramework

A legacy universal framework cannot distinguish arm64 device from arm64 simulator; the proper fix is an XCFramework with both slices.

How to fix it

Use an XCFramework with the simulator slice

  1. Rebuild the dependency as an XCFramework that includes ios-arm64-simulator.
  2. Replace the fat framework with the XCFramework in the project.
  3. Clean DerivedData and rebuild so the new module is picked up.
Terminal
xcodebuild -create-xcframework \
  -framework device/SomeKit.framework \
  -framework simulator/SomeKit.framework \
  -output SomeKit.xcframework

Build for a matching simulator architecture

If you must keep an x86_64-only framework, run the simulator build under Rosetta or target an x86_64 simulator destination.

Terminal
arch -x86_64 xcodebuild -scheme App \
  -destination 'platform=iOS Simulator,name=iPhone 16' build

How to prevent it

  • Distribute binary dependencies as XCFrameworks with all needed slices.
  • Build CI simulator targets with arm64 on Apple silicon runners.
  • Verify a framework includes ios-arm64-simulator before relying on it.

Frequently asked questions

What causes ""Could not find module ... for target""?
On Apple silicon runners the simulator target is arm64, but the dependency was only built for x86_64 simulator, so no matching module exists.
How do I fix "Could not find module ... for target"?
Use an XCFramework with the simulator slice

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card