Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path returned by Bundle.module.path(forResource:ofType:) on Windows is incorrect #8264

Open
1 task done
adam-fowler opened this issue Jan 31, 2025 · 0 comments
Open
1 task done
Labels

Comments

@adam-fowler
Copy link

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

When calling Bundle.module.path(forResource:ofType:) on Windows the path returned has an additional '/' prefixed to the file name.

Expected behavior

Path returned by Bundle.module.path(forResource:ofType:) does not return a path starting with /.

Actual behavior

Path returned by Bundle.module.path(forResource:ofType:) starts with a /.

This is most likely caused by the URLs that Bundle generates which include three forward slashes.

Steps to reproduce

  • Add "test.txt" resource file to swift package
  • Call Bundle.module.path(forResource: "test", ofType: "txt")

I found this issue while trying to load resources in a test target.

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

Swift version 6.0 (swift-6.0-RELEASE)
Target: x86_64-unknown-windows-msvc

@adam-fowler adam-fowler changed the title Path returned by Bundle.module.path(forResource:ofType:) on Windows in incorrect Path returned by Bundle.module.path(forResource:ofType:) on Windows is incorrect Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant