I\'m trying to use a resource file in unit tests and access it with Bundle.path
, but it returns nil.
This call in MyProjectTests.swift returns nil:
starting on Swift 5.3, thanks to SE-0271, you can add bundle resources on swift package manager by adding resources
on your .target
declaration.
example:
.target(
name: "HelloWorldProgram",
dependencies: [],
resources: [.process(Images), .process("README.md")]
)
if you want to learn more, I have written an article on medium, discussing this topic. I don't specifically discuss .testTarget
, but looking on the swift proposal, it looks alike.