From 4235bc71489a29e97ebd5f06c53193267001cfa3 Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Thu, 19 Feb 2026 12:26:47 -0800 Subject: [PATCH] Fix test resources in Xcode when running in symlinked directory `/tmp` on macOS is a symlink to `/private/tmp`. We need to canonicalize both paths with `(path as NSString).standardizingPath` before we call `.hasPrefix` on them. --- Sources/SkipBuild/Commands/TranspileCommand.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/SkipBuild/Commands/TranspileCommand.swift b/Sources/SkipBuild/Commands/TranspileCommand.swift index 4d606e63..7188c79a 100644 --- a/Sources/SkipBuild/Commands/TranspileCommand.swift +++ b/Sources/SkipBuild/Commands/TranspileCommand.swift @@ -1035,8 +1035,13 @@ struct TranspileCommand: TranspilePhase, StreamingCommand { .appending(component: "Resources") for resourceFile in resourceURLs.map(\.path).sorted() { - guard let resourceSourceURL = moduleNamePaths.compactMap({ (_, folder) in - resourceFile.hasPrefix(folder) ? URL(fileURLWithPath: resourceFile.dropFirst(folder.count).trimmingCharacters(in: CharacterSet(charactersIn: "/")).description, relativeTo: URL(fileURLWithPath: folder, isDirectory: true)) : nil }).first else { + let resourceFileCanonical = (resourceFile as NSString).standardizingPath + guard let resourceSourceURL = moduleNamePaths.compactMap({ (_, folder) -> URL? in + let folderCanonical = (folder as NSString).standardizingPath + guard resourceFileCanonical.hasPrefix(folderCanonical) else { return nil } + let relativePath = String(resourceFileCanonical.dropFirst(folderCanonical.count)).trimmingCharacters(in: CharacterSet(charactersIn: "/")) + return URL(fileURLWithPath: relativePath, relativeTo: URL(fileURLWithPath: folderCanonical, isDirectory: true)) + }).first else { // skip over resources that are not contained within the Resources/ folder (such as files in the Skip/ folder, which contain metadata that should not be copied) msg(.trace, "no module root parent for \(resourceFile)") continue