You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it reproducible with SwiftPM command-line tools
(swift build, swift test, swift package, etc)?
Confirmed reproduction steps with SwiftPM CLI.
Description
Note
I have provided an example project with CI hooked up to help aid in reproducing this issue.
I have discovered a very odd issue that's very hard to pinpoint in the (non-xcode) swift toolchain, here is where I ran into the bug(view the raw log for this build) and then search for the following text: error: failed to build module 'SwiftUI', even more insane is that this error caused the build time to swell up to nearly 4x over:
typical build time for this project is 29m 11s
however this bug induced a 1h 44m 58s build 😅
It appears on the non-xcode swift toolchain, if a Swift .target() has a .product() dependency which attempts to make a module alias, in my case, from SwiftCrossUI → SwiftUI, the condition clause is entirely ignored and the module is aliased on all platforms regardless of what is listed in the .when(platforms: [.linux, .windows]) array, which means macOS is for some reason experiencing the module aliasing seen here in the SwiftPM package manifest:
It then errors about failing to build the SwiftUI module, reporting that this SDK is suddenly not supported by the compiler, due to the existence of this single offending line in the package manifest:
moduleAliases: ["SwiftCrossUI":"SwiftUI"]
Expected behavior
I expected the usage of moduleAliases: ["SwiftCrossUI": "SwiftUI"]:
to create a module alias from SwiftCrossUI → SwiftUI.
when used in conjunction with condition: .when(platforms: [.linux, .windows])
only for the Linux and Windows platforms.
So that in my swift code I could write code like the following:
// SomeFile.swift
import SwiftUI
// do cross platform UI things...
Actual behavior
The usage of moduleAliases: ["SwiftCrossUI": "SwiftUI"]:
to create a module alias from SwiftCrossUI → SwiftUI.
when used in conjunction with condition: .when(platforms: [.linux, .windows])
somehow broke macOS.
// SomeFile.swift
import SwiftUI
^~~~~~~
error: failed to build module 'SwiftUI'
// do cross platform UI things...
furby-tm
changed the title
Swift (non-xcode) Toolchain Bug with Module Aliases on Conditional Products.
Swift Module Aliases Bug with Conditional Products.
Mar 20, 2024
Is it reproducible with SwiftPM command-line tools
Description
Note
I have provided an example project with CI hooked up to help aid in reproducing this issue.
I have discovered a very odd issue that's very hard to pinpoint in the (non-xcode) swift toolchain, here is where I ran into the bug(view the raw log for this build) and then search for the following text:
error: failed to build module 'SwiftUI'
, even more insane is that this error caused the build time to swell up to nearly 4x over:It appears on the non-xcode swift toolchain, if a Swift
.target()
has a.product()
dependency which attempts to make a module alias, in my case, from SwiftCrossUI → SwiftUI, thecondition
clause is entirely ignored and the module is aliased on all platforms regardless of what is listed in the.when(platforms: [.linux, .windows])
array, which means macOS is for some reason experiencing the module aliasing seen here in the SwiftPM package manifest:It then errors about failing to build the SwiftUI module, reporting that this SDK is suddenly not supported by the compiler, due to the existence of this single offending line in the package manifest:
Expected behavior
I expected the usage of
moduleAliases: ["SwiftCrossUI": "SwiftUI"]
:condition: .when(platforms: [.linux, .windows])
So that in my swift code I could write code like the following:
Actual behavior
The usage of
moduleAliases: ["SwiftCrossUI": "SwiftUI"]
:condition: .when(platforms: [.linux, .windows])
Steps to reproduce
cd SwiftUIToolchainBug
code .
Swift Package Manager version/commit hash
Swift 5.9.2
Swift & OS version (output of
swift --version ; uname -a
)The text was updated successfully, but these errors were encountered: