@@ -87,7 +87,7 @@ struct DepsPackage {
8787 try Data ( ) . write ( to: emptyFilePath. url)
8888 }
8989
90- /* Note: openpty is more or less deprecated and we should use the more complex but POSIX compliant to open the PTY.
90+ /* Note: openpty is more or less deprecated and we should use the more complex but POSIX compliant way to open the PTY.
9191 * See relevant test in swift-process-invocation for more info. */
9292 var slaveRawFd : Int32 = 0
9393 var masterRawFd : Int32 = 0
@@ -160,7 +160,17 @@ struct DepsPackage {
160160 }
161161 /* Now swift has given us the arguments it thinks are needed to start the script.
162162 * Spoiler: they are not enough!
163- * When the deps contain an xcframework dependency, we have to add the -I option for swift to find the headers of the frameworks. */
163+ * - When the deps contain an xcframework dependency, we have to add the -I option for swift to find the headers of the frameworks.
164+ * - Starting w/ Swift 6, the arguments given by the REPL invocation give an incorrect include search path:
165+ * we must add `/Modules` to the include path.
166+ * Because we still want to be compatible w/ Xcode < 6, we add the fixed search path before the one given by the REPL invocation. */
167+ /* Add `/Modules` variants import options for Swift 6. */
168+ for (idx, arg) in ret. enumerated ( ) {
169+ if arg. hasPrefix ( " -I " ) {
170+ ret. insert ( arg + " /Modules " , at: idx)
171+ }
172+ }
173+ /* Add xcframework import options. */
164174 let artifactsFolder = packageFolder. appending ( " .build/artifacts " )
165175 if let directoryEnumerator = fm. enumerator ( at: artifactsFolder. url, includingPropertiesForKeys: nil ) {
166176 while let url = directoryEnumerator. nextObject ( ) as! URL ? {
0 commit comments