[For simulator] How to build Swift packages as x86_64 in Xcode and M1 mac (Apple silicon) without using rosetta

On M1 mac (Apple Silicon chips), Xcode runs on arm64.

How can we build the packages as x86_64 in SwiftPM that integrates with Xcode?

Xcode builds the target as arm64 for simulator unless specifying excluded archs option.

In some cases, the project would be forced to use x86_64 for simulator build since using external prebuilt frameworks only have arm64 for the device and x86_64 for the simulator. with specifying EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64

However, I could not find a way to specify that in the packages managed by SwiftPM.

From this, Xcode builds packages as arm64 then builds application target as x86_64, linking phase would fail with not found modules in the arch.

What can we do when we are forced to use still x86_64 on M1 mac?

I have the exact same issue currently. Tried everything I can find online to fix this issue, but the local swift package keeps only getting build for arm64 (even when explicitly ignoring that architecture in build settings)

Do you know a fix to build external SPM sdks as arm64? In my project i've a few external sdks but i can't build the entire project to arm64 errors...

I also have the same issue. The only temporary solution I've found is rebuilding all the package dependencies with xcodebuild for x86_64 in run script build phases, but that's far from ideal. I really hope that there will be an option for somehow setting the target architecture for the compilation of the packages also, at least when building for simulator.

+1 me too. This is really frustrating. Filing "feedback" with Apple, hopefully it bears fruit.

Same problem here. Such a bummer. I work on a project that has some dependencies in both CocoaPods and SwiftPM. Some of the CocoaPods dependencies are prebuilt assuming the simulator is x86, so I have to exclude arm64 from the simulator build settings for all CocoaPods dependencies. This works ok on its own (although it means the simulator runs in Rosetta). But there's no way to get SwiftPM to also build dependencies for x86 other than to run Xcode in Rosetta too.

I'm the same boat. I have a new Mac Studio Ultra but my iOS app's main dependency currently only builds for x86 for simulators. I can't seem to force all the SPM packages it relies on to build x86 simulator versions :(

Apple really needs an Xcode setting to tell SPM how to build. It seems CocoaPods can do this https://blog.sudeium.com/2021/06/18/build-for-x86-simulator-on-apple-silicon-macs/

The solution is to update your dependencies to include an arm64 build for the simulators on Apple silicon Macs. This is covered in Technote 3117:

Important: Do not use EXCLUDED_ARCHS with pre-compiled libraries that are not updated with support for the iOS, watchOS, or tvOS simulators on Apple silicon. Rebuild the library using the information in Update Pre-Compiled Libraries with Apple Silicon Support.

and

 If the library is from a vendor, contact the vendor for an updated XCFramework supporting Apple silicon.

[For simulator] How to build Swift packages as x86_64 in Xcode and M1 mac (Apple silicon) without using rosetta
 
 
Q