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

Recently, I have purchased a M1 Mac mini and have a fairly large project with in house created SPM dependencies. Our dependencies are dynamic frameworks, and currently, they aren't very complex.

Our project has the following settings where:

Build Active Architectures = true for all configurations other than Release
And I've been messing around with the Excluded Architectures option to remove arm64 from simulator builds.

With this being noted, although we have in-house SPM SDKs (non binary deliveries), it would seem our project is flagging up Could not find module 'XXXX' for target 'x8664-apple-ios-simulator'; found: arm64, arm64-ios-simulator where derived data is showing arm64 is being resolved for a standard simulator build (iPhone 12 mini 14.3) via Xcode 12.2 and 12.3. Does anyone know why this is happening and is there a configuration that SPM is not respecting regarding Valid architectures or building for active architectures causing it to evaluate an incorrect arch type. Everything does build correctly when evaluated against Any iOS device (as this does not take x8664 as an arch type) and evaluates correctly on non M1 Macs for the remaining sim arch types.

Edit:

It's fairly easy to repro this situation with the following steps:

Create new Xcode project (UIKit + Swift)
Create Embedded dynamic framework bundle
Create Swift Package (dynamic)
Link Swift Package to Embedded dynamic framework bundle (make sure it’s not embedded as we only want it linked)
Embed dynamic framework bundle to main project
Embed dynamic Swift Package framework to main project

Add flag to “Exclude Architectures” for “Any iOS Simulator SDK” to exclude arm64 architectures (ensuring any existing FAT binaries do not have an arm64 slice running in the simulator).

Build project.

Add flag to “Exclude Architectures” for “Any iOS Simulator SDK” to exclude arm64 architectures (ensuring any existing FAT binaries do not have an arm64 slice running in the simulator).

Don't exclude arm64 for simulator builds. Instead, ensure that any pre-built binaries are XCFrameworks, which will separate the device and simulator configurations into separate binaries. A binary with device and simulator architectures mixed together has never been a supported configuration. XCFrameworks were introduced to solve this problem, and thus all of the downstream build configuration issues stemming from architecture matching like what you're encountering here.
@edford how do I tell SPM to build an XCFramework? found your answer while searching around about this and think you are right: I had excluded per all the other threads (which made no sense to me, seems like a solution for someone on intel machines), but the reason I am sure you have the right answer here is that the latest version of Carthage recommended that I add a switch to build those dependencies as XCFrameworks.

In my case, I have added test target after the pod init, install etc.. And I saw, adding test target block in podfile solved my problem.

Example;

target 'SampleProject' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for SampleProject

  target 'SampleProjectTests' do
    inherit! :search_paths
    # Pods for testing
  end
end
Could not find module 'XXXX' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-ios-simulator
 
 
Q