File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
utils/swift-xcodegen/Sources/SwiftXcodeGen Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -200,12 +200,17 @@ struct SwiftTargets {
200
200
201
201
guard let buildArgs = try computeBuildArgs ( for: rule) else { return }
202
202
203
- let moduleName = buildArgs. lastValue ( for: . moduleName)
203
+ // Pick up the module name from the arguments, or use an explicitly
204
+ // specified module name if we have one. The latter might be invalid so
205
+ // may not be part of the build args (e.g 'swift-plugin-server'), but is
206
+ // fine for generation.
207
+ let moduleName = buildArgs. lastValue ( for: . moduleName) ??
208
+ rule. attributes [ . swiftModuleName] ? . value
204
209
guard let moduleName else {
205
210
log. debug ( " ! Skipping Swift target with output \( primaryOutput) ; no module name " )
206
211
return
207
212
}
208
- let moduleLinkName = rule. attributes [ . swiftLibraryName] ? . value ??
213
+ let moduleLinkName = rule. attributes [ . swiftLibraryName] ? . value ??
209
214
buildArgs. lastValue ( for: . moduleLinkName)
210
215
let name = moduleLinkName ?? moduleName
211
216
Original file line number Diff line number Diff line change @@ -557,8 +557,10 @@ fileprivate final class ProjectGenerator {
557
557
558
558
applySubstitutions ( to: & buildArgs, target: target, targetInfo: targetInfo)
559
559
560
+ // Follow the same logic as swift-driver and set the module name to 'main'
561
+ // if we don't have one.
560
562
let moduleName = buildArgs. takePrintedLastValue ( for: . moduleName)
561
- buildSettings. common. PRODUCT_MODULE_NAME = moduleName
563
+ buildSettings. common. PRODUCT_MODULE_NAME = moduleName ?? " main "
562
564
563
565
// Emit a module if we need to.
564
566
// TODO: This currently just uses the build rule command args, should we
You can’t perform that action at this time.
0 commit comments