Swift Package is built as a universal binary in main project


Following line from Xcode build log shows that Xcode is building swift package dependencies as universal binaries

CreateUniversalBinary .../UIComponents.o normal arm64\ x86_64 (in target 'UIComponents' from project 'PlatformPackages')

Also confirmed with lipo

lipo -info UIComponents.o
Architectures in the fat file: UIComponents.o are: x86_64 arm64 

Is it possible to build swift package for active architecture only? Or for selected architectures based on configuration.

AFAIK, Swift packages in Xcode are built for the active architecture in debug mode and universally in release mode and there's no way to control the behavior. You may try changing the setting in your project, but I don't believe Xcode's SPM integration passes that setting through.

1 Like

That is correct, packages behave like projects do by default here and there's no control over the build setting. Build settings of client projects generally don't apply to packages in any way.

1 Like

Could swift package itself specify build settings in Package.swift?

For what it's worth, I've filed FB9915302 about this. It's a major workflow issue for apps which need to be built with optimisations to run well enough to be tested – the compile times are very lengthy regardless and building for architectures you're not going to use only makes it worse.

I'll also add that per-target optimisation settings would be very useful – it's often the case that I'm working on a particular package and want that to be built in debug mode, but still need other packages it depends on to be in release mode so the app is usable.

1 Like

@Torust just curious if you heard back from Apple on this?

Nothing at this stage.

1 Like