Search code examples
iosswiftxcodebuildxcode14

When compiling with Xcode14 I get Error unsupported Swift architecture. How to solve this?


After switching to xcode 14 build system. Generated headers for our pod frameworks start 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
#if 0
#elif defined(__x86_64__) && __x86_64__
// Generated by Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
... bridging for x86
#else
#error unsupported Swift architecture
#endif

If I look in headers I see that scenarios:

arm64 defined and x86 defined - should be OK arm64 defined and x86 not - should be error arm64 not defined and x86 does - should be error So to avoid error both architectures should be defined. And this cause client application build fail with error: error unsupported Swift architecture.

Even if ONLY_ACTIVE_ARCH = 0, that probably should be the hotfix. I still getting this error.

Does anyone know why precompiled headers now requires both architectures. And how to fix build error?


Solution

  • SOLUTION THAT HELPS US:

    When building frameworks we were using -arch arm64 or -arch arm64 and build frameworks for different architectures and then join them.

    Apple changed the way they generate bridging headers this solution fails because of format of header I attached in question.

    The solution for us is just remove -arch and build fat framework.