@@ -48,7 +48,10 @@ struct Plugin: CommandPlugin {
48
48
" --package-name " , context. package . displayName,
49
49
" --wit-output-path " , witOutputPath. string,
50
50
" --swift-output-path " , swiftOutputPath. string,
51
- " -I " , buildPath. string
51
+ " -I " , buildPath. string,
52
+ // SwiftPM 6.0 and later emits swiftmodule files into a separate directory
53
+ // https://github.com/swiftlang/swift-package-manager/pull/7212
54
+ " -I " , buildPath. appending ( [ " Modules " ] ) . string,
52
55
]
53
56
if let sdk {
54
57
arguments += [ " -sdk " , sdk]
@@ -74,12 +77,28 @@ struct Plugin: CommandPlugin {
74
77
return nil
75
78
}
76
79
for line in contents. split ( separator: " \n " ) {
77
- let prefix = " executable: \" "
78
- if line. hasPrefix ( prefix) , line. hasSuffix ( " /swiftc \" " ) {
79
- let pathStart = line. index ( line. startIndex, offsetBy: prefix. count)
80
- let pathEnd = line. index ( before: line. endIndex)
81
- let executablePath = line [ pathStart..< pathEnd]
82
- return String ( executablePath)
80
+ do {
81
+ let prefix = " executable: \" "
82
+ if line. hasPrefix ( prefix) , line. hasSuffix ( " /swiftc \" " ) {
83
+ let pathStart = line. index ( line. startIndex, offsetBy: prefix. count)
84
+ let pathEnd = line. index ( before: line. endIndex)
85
+ let executablePath = line [ pathStart..< pathEnd]
86
+ return String ( executablePath)
87
+ }
88
+ }
89
+ do {
90
+ // Swift 6.0 no longer uses llbuild's built-in swift tool. Instead,
91
+ // it uses the generic shell tool with full arguments.
92
+ // https://github.com/swiftlang/swift-package-manager/pull/6585
93
+ let prefix = " args: "
94
+ if line. hasPrefix ( prefix) {
95
+ let argsString = line [ line. index ( line. startIndex, offsetBy: prefix. count) ... ]
96
+ guard let args = try ? JSONDecoder ( ) . decode ( [ String ] . self, from: Data ( argsString. utf8) ) ,
97
+ let swiftc = args. first ( where: { $0. hasSuffix ( " /swiftc " ) } ) else {
98
+ continue
99
+ }
100
+ return swiftc
101
+ }
83
102
}
84
103
}
85
104
return nil
0 commit comments