Skip to content

Commit b244155

Browse files
committed
Fix swift-sh for Swift 6
1 parent 061dac4 commit b244155

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Sources/swift-sh/Helpers/DepsPackage.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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? {

Sources/swift-sh/OptionGroups/BuildAndRunOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class BuildAndRunOptions : ParsableArguments {
1919
var skipPackageOnNoRemoteModules = true
2020

2121
@Flag(name: .long, inversion: .prefixedNo)
22-
var buildDependenciesInReleaseMode = false
22+
var buildDependenciesInReleaseMode = true
2323

2424
@Flag(name: .long, inversion: .prefixedNo)
2525
var disableSandboxForPackageResolution = false

0 commit comments

Comments
 (0)