Skip to content

[Commands] Migrate: Group manifest update errors per target #8677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Sources/Commands/PackageCommands/Migrate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,11 @@ extension SwiftPackageCommand {
print("> Updating manifest.")
for module in modules.map(\.module) {
print("> Adding feature(s) to '\(module.name)'.")
for feature in features {
self.updateManifest(
for: module.name,
add: feature,
using: swiftCommandState
)
}
self.updateManifest(
for: module.name,
add: features,
using: swiftCommandState
)
}
}

Expand Down Expand Up @@ -179,27 +177,29 @@ extension SwiftPackageCommand {

private func updateManifest(
for target: String,
add feature: SwiftCompilerFeature,
add features: [SwiftCompilerFeature],
using swiftCommandState: SwiftCommandState
) {
typealias SwiftSetting = SwiftPackageCommand.AddSetting.SwiftSetting

let setting: (SwiftSetting, String) = switch feature {
case .upcoming(name: let name, migratable: _, enabledIn: _):
(.upcomingFeature, "\(name)")
case .experimental(name: let name, migratable: _):
(.experimentalFeature, "\(name)")
let settings: [(SwiftSetting, String)] = features.map {
switch $0 {
case .upcoming(name: let name, migratable: _, enabledIn: _):
(.upcomingFeature, "\(name)")
case .experimental(name: let name, migratable: _):
(.experimentalFeature, "\(name)")
}
}

do {
try SwiftPackageCommand.AddSetting.editSwiftSettings(
of: target,
using: swiftCommandState,
[setting]
settings
)
} catch {
print(
"! Couldn't update manifest due to - \(error); Please add '.enable\(feature.upcoming ? "Upcoming" : "Experimental")Feature(\"\(feature.name)\")' to target '\(target)' settings manually."
"error: Couldn't update manifest for '\(target)' (\(error)). Please enable '\(features.map(\.name).joined(separator: ", "))' features manually."
)
}
}
Expand Down