Skip to content
Latchkey

xcodebuild "building for iOS Simulator, but linking ... built for iOS" arch slice in CI

On Apple silicon runners the iOS Simulator is arm64, the same architecture as a real device. A framework that ships only the device arm64 slice links into a simulator build with the wrong platform, and the linker rejects it.

What this error means

The simulator build fails with "building for iOS Simulator, but linking in object file (.../SomeKit) built for iOS" or "ld: in ..., building for iOS Simulator, but linking ... built for iOS".

xcodebuild
ld: building for 'iOS-simulator', but linking in object file
(SomeKit.framework/SomeKit) built for 'iOS'
clang: error: linker command failed with exit code 1

Common causes

A device-only arm64 framework

The binary framework has an ios-arm64 slice but no ios-arm64-simulator slice, so on Apple silicon the simulator build links a device object.

A fat framework cannot separate the two arm64 platforms

Universal fat frameworks tag arm64 once and cannot distinguish device from simulator; only XCFrameworks carry both platform variants.

How to fix it

Adopt an XCFramework with a simulator slice

  1. Replace the device-only framework with an XCFramework that includes ios-arm64-simulator.
  2. Clean DerivedData so the new slice is used.
  3. Rebuild the simulator target.
Terminal
xcodebuild -create-xcframework \
  -framework device/SomeKit.framework \
  -framework simulator/SomeKit.framework \
  -output SomeKit.xcframework

Build the simulator target under x86_64 as a stopgap

If only a device/x86_64 framework exists, run the simulator build via Rosetta or exclude arm64 for the simulator SDK.

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

How to prevent it

  • Distribute binary frameworks as XCFrameworks with device and simulator slices.
  • On Apple silicon runners, ensure simulator slices are arm64.
  • Avoid blanket EXCLUDED_ARCHS=arm64 as a permanent fix; prefer XCFrameworks.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →