Closed
Description
Describe the bug
Using Bundle.module.url(forResource:, withExtension:,subdirectory:)
results in error message "Foundation/NSCFString.swift:119: Fatal error: Constant strings cannot be deallocated"
Steps To Reproduce
Steps to reproduce the behavior:
- Create a new package
mkdir swiftbug; cd swiftbug; swift package init
- In Package.swift, add a resource to the testTarget:
.testTarget(
name: "swiftbugTests",
dependencies: ["swiftbug"],
resources: [
.copy("Resources")
]),
- Create a resource:
mkdir Tests/swiftbugTests/Resources; touch Tests/swiftbugTests/Resources/dummy.png
- Modify the test in Tests/swiftbugTests/swiftbugTests.swift to match:
func testExample() async throws {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct
// results.
XCTAssertEqual(swiftbug().text, "Hello, World!")
_ = Bundle.module.url(forResource: "filename", withExtension: nil, subdirectory: "Resources")
}
- Run the test:
swift test
Expected behavior
Tests should finish without an error.
Actual result
Building for debugging...
[20/20] Linking swiftbugPackageTests.xctest
Build complete! (4.82s)
Test Suite 'All tests' started at 2022-10-10 17:57:06.166
Test Suite 'debug.xctest' started at 2022-10-10 17:57:06.171
Test Suite 'swiftbugTests' started at 2022-10-10 17:57:06.171
Test Case 'swiftbugTests.testExample' started at 2022-10-10 17:57:06.172
Foundation/NSCFString.swift:119: Fatal error: Constant strings cannot be deallocated
error: Exited with signal code 4
Environment (please fill out the following information)
- OS: Debian Linux
- Self compiled swiftc: LLVM c205842748e1789, Swift 1f8a5d6045262bb
Additional context
Might be related to/regression of #3785
Metadata
Metadata
Assignees
Labels
No labels