Skip to content

Use Swift SDK manifest path as imposed SDKROOT during specialization#1326

Draft
MaxDesiatov wants to merge 3 commits into
swiftlang:mainfrom
MaxDesiatov:maxd/unable-to-find-sdk
Draft

Use Swift SDK manifest path as imposed SDKROOT during specialization#1326
MaxDesiatov wants to merge 3 commits into
swiftlang:mainfrom
MaxDesiatov:maxd/unable-to-find-sdk

Conversation

@MaxDesiatov

@MaxDesiatov MaxDesiatov commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Synthesized Swift SDKs (registered via SDKRegistry.synthesizedSDK) use the SDK's manifest path as their canonical name and not the platform name. When imposing SDKROOT for specialization, falling back to platform.sdkCanonicalName e.g. "webassembly") leaves the SDK lookup with no match and the build fails with error: unable to find sdk '<platform>'. When the active run destination is a Swift SDK targeting this same platform, we instead use its identifier (runDestination.sdk = the manifest path) so the lookup hits the synthesized SDK directly.

Resolves #1325.

@MaxDesiatov MaxDesiatov added the bug Something isn't working label Apr 20, 2026
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

1 similar comment
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@owenv

owenv commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator

This might be addressedI think this is likely addressed by #1318, which is not really windows-specific, do you want to try rebasing the test on that?

@MaxDesiatov MaxDesiatov force-pushed the maxd/unable-to-find-sdk branch from 521dfb1 to bcab4db Compare April 21, 2026 10:52
/// 1. `SpecializationParameters.imposed(on:workspaceContext:)`
/// in `swift-build/Sources/SWBCore/DependencyResolution.swift` — exercised by `MyLibrary`,
/// which is reachable via specialization from `MyApp`.
/// 2. `addRunDestinationSettingsPlatformSDK` in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What package triggers this case?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectation is package targets should always have PIF with SDKROOT: auto

@MaxDesiatov MaxDesiatov Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repro steps are given in the linked issue, but essentially all packages targeting Wasm and depending on JavaScriptKit (which is arguably the vast majority of SwiftPM packages for Wasm) are broken and not buildable with SwiftBuild at this point #1325

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those packages don't produce a non-auto SDKROOT though, so the change to the else branch of addRunDestinationSettingsPlatformSDK should be a no-op

Comment thread Sources/SWBCore/DependencyResolution.swift Outdated
Comment thread Sources/SWBCore/DependencyResolution.swift Outdated
Co-authored-by: Max Desiatov <m_desiatov@apple.com>
@MaxDesiatov

Copy link
Copy Markdown
Contributor Author

@swift-ci test

@owenv owenv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing offline this LGTM but the test needs .requireSDKs(.macOS) before CI will pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unable to find sdk '<platform>' when building Swift package against a Swift SDK with target-platform specialization

2 participants