Error 'unsupported Swift architecture' in generated -Swift.h file

We are developing a bunch of xcframeworks, that are using some other xcframeworks, that are distributed via cocoapods.

Problem

After switching to xcode 14 build system, generated headers for our frameworks started looking like that:

#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
... bridging for arm64
#else
#error unsupported Swift architecture
#endif

For that part of developers and consumers of our framework, which uses Intel macs, it leads to errors, while trying to build for simulator.

Sample

I've created sample project that, reproduces issue and also includes script for creating xcframework, which is similar to the one we use - create-xcframework.sh.
I found out that the presence of pods affects this. If the framework does not use them, then there is no such error. Code fro creating xcframework is the same and can be found in branch no-pods-no-issues

For creating xcframeworks I've followed instructions from Creating a multiplatform binary framework bundle.
I've tried to resolve error following TN3117: Resolving architecture build errors on Apple silicon.

Common issues

I've found some common issues on stackoverflow and apple forum, but there is no working solution in any of them.

Questions

How to force generated swift header to contain define for x86_64 alongside with arm64?
Which setting leads to that kind of generation?
How should pods project be changed to avoid that side effects?

1 Like