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

**URL:** <https://forums.swift.org/t/error-unsupported-swift-architecture-in-generated-swift-h-file/66901>\
**Category:** Using Swift\
**Tags:** binary-framework, xcodebuild, framework, xcframework\
**Created:** [August 23, 2023, 12:48pm UTC](https://forums.swift.org/t/error-unsupported-swift-architecture-in-generated-swift-h-file/66901 "2023-08-23T12:48:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asevko](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/asevko/32/29790_2.png) [@asevko](https://forums.swift.org/u/asevko)\
**Post date:** [August 23, 2023, 12:48pm UTC](https://forums.swift.org/t/error-unsupported-swift-architecture-in-generated-swift-h-file/66901/1 "2023-08-23T12:48:11Z")

</div>

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:

```objc
#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.

 ![Screenshot 2023-08-23 at 14.40.57](https://global.discourse-cdn.com/swift/original/3X/1/6/16e40b700ce9d13d30b4f8d8baf1d54f5584c38a.png)

## Sample

I've created [sample project](https://github.com/asevko/unsupported-swift-architecture-demo) that, reproduces issue and also includes script for creating xcframework, which is similar to the one we use - [create-xcframework.sh](https://github.com/asevko/unsupported-swift-architecture-demo/blob/main/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](https://github.com/asevko/unsupported-swift-architecture-demo/tree/no-pods-no-issues)_

For creating `xcframeworks` I've followed instructions from [Creating a multiplatform binary framework bundle](https://developer.apple.com/documentation/Xcode/creating-a-multi-platform-binary-framework-bundle).  
I've tried to resolve error following [TN3117: Resolving architecture build errors on Apple silicon](https://developer.apple.com/documentation/technotes/tn3117-resolving-build-errors-for-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.

- [When compiling with Xcode14 I get Error unsupported Swift architecture. How to solve this?](https://stackoverflow.com/questions/74517344/when-compiling-with-xcode14-i-get-error-unsupported-swift-architecture-how-to-s)
- [Xcode 14.2 build fail](https://stackoverflow.com/questions/75922282/xcode-14-2-build-fail)
- [Error unsupported Swift architecture.](https://stackoverflow.com/questions/74517344/when-compiling-with-xcode14-i-get-error-unsupported-swift-architecture-how-to-s)

## 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?

---

<div class="post-metadata">

**Author:** ![jerrykrinock](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jerrykrinock/32/33464_2.png) [@jerrykrinock](https://forums.swift.org/u/jerrykrinock)\
**Post date:** [July 17, 2024, 4:26am UTC](https://forums.swift.org/t/error-unsupported-swift-architecture-in-generated-swift-h-file/66901/2 "2024-07-17T04:26:55Z")

</div>

I had this exact same problem, except that I was not using cocoapods, but it occurred when I used a home-made local Swift package. In addition to going down the same rabbit hole of "debugging" the generated header and finding the same problem as Aliaksei described, I also found that I needed to add a reverse-engineered User Header Search Path to Build Settings, so that this generated header would be included, and these Paths were different for Debug and Release. How could Apple have made using local packages so hard?

Answer, thanks to [Brian Webster](https://www.fatcatsoftware.com/about/): Don't try to include the problematic generated Swift header of a local package or cocoapod. Instead, use the relatively new `@import` feature of Xcode to import the package's module. I reckon it would work similarly with your cocoapods. To do this, find all occurrences of

`#import "MyPackage-Swift.h"`

and replace with

`@import MyPackage;`

If it doesn't work, verify that Build Settings `Enable Modules` and `Link Frameworks Automatically` are set to their default `YES` values.
