Linux only dependency leads to resolving error for iOS

Hello Swift community !

We are experiencing an issue with SPM on a specific case. The issue has been reported here : Missing OpenCombine in Package.resolved file · pointfreeco/combine-schedulers · Discussion #112 · GitHub .

The library on this repo (combine-schedulers) has in its dependencies OpenCombine but it is only used in the target for Linux platform. Its package.swift can be found here : combine-schedulers/Package.swift at main · pointfreeco/combine-schedulers · GitHub

Our iOS project uses combine-schedulers and this doesn’t cause issue on XCode 26 as OpenCombine is just ignored and doesn’t appear in package.resolved

However the problem occurs on our CI where the flag disableAutomaticPackageResolution is set. Apparently SPM gets confused, somehow thinks OpenCombine is necessary and complains about its absence in the package.resolved. The error :

Could not resolve package dependencies: an out-of-date resolved file was detected at 
/Volumes/workspace/repository/App.xcworkspace/xcshareddata/swiftpm/Package.resolved, 
which is not allowed when automatic dependency resolution is disabled;
 please make sure to update the file to reflect the changes in dependencies. 
Running resolver because the following dependencies were added: 'opencombine' (https://github.com/OpenCombine/OpenCombine.git)

As a workaround we can add OpenCombine directly in our iOS project dependencies but this is a shame as we don’t use it.

Is this a known limitation of SPM ?

Thanks in advance

if its an xcode project, perhaps you can use the excluded sourced feature EXCLUDED_SOURCE_FILE_NAMES with a pattern that matches opencombine.

link: EXCLUDED_SOURCE_FILE_NAMES

※ i’m assuming your linux builds aren’t using xcodebuild but even if they are, you could work around that with target specific configs i think

※ there is also EXCLUDED_EXPLICIT_TARGET_DEPENDENCIES but i’ve never used that before…

Had similar problem with Swift 6.2.0 and traits, after installing Swift 6.2.3 and running swift package resolve, it added the dependency to the resolved file for me. After the resolved file is fixed, the project should build fine with other Swift versions.

Having the trait is totally useless in this project. swift build --disable-default-traits fails on Linux, the trait doesn't affect anything else on other platforms. So my advice would be to just remove the trait from the project.

We’ll give this a try on XCode 26.2 as we’ve only tested on 16.2 for now, thanks !

I’m not the one maintaining the combine-schedulers lib and I’m not familiar with how traits work. But this remark may be interesting to @stephencelis or @mbrandonw ^^

Sadly it does not appear to be "totally useless." In practice the trait gates the OpenCombine dependency from being downloaded and shown in Xcode's sidebar. Eliminating the trait and simply depending on the .when platforms list does not appear to be enough.

We may be exploiting an Xcode/SPM bug/quirk, but the iOS community is generally averse to too many dependencies, and so we're trying to minimize the footprint on Apple platforms.

1 Like

Are you sure it's not downloaded instead of just missing from the sidebar because it's also missing from the resolved file?

It does unfortunately appear to download into derived data, so the main effect is cosmetic, but one that folks have complained about.

There is always the option to have a separate package for just the prebuilt xcframework, like how Lottie does it: GitHub - airbnb/lottie-spm: Swift Package Manager support for Lottie, an iOS library to natively render After Effects vector animations