Is it possible to set LD_RUNPATH_SEARCH_PATHS in tests target in SPM package?

I have a SPM package which depends on precompiled dylib library.
Consider the following:

MyPackage/Sources/FooBar
MyPackage/Tests/FooBarTests
MyPackage/Tests/FooBarTests/Resources/MyLib.dylib

FooBar target can compile, because it can search for headers of MyLib.dylib library.
But tests target FooBarTests requires MyLib.dylib library for compilation and running.
So, I added this library into Resources directory of FooBarTests.

A part of package is

.target(name: "FooBar"),
.testTarget(
  name: "FooBar",
  depenedencies: ["FooBar"],
  resources: [.copy("Resources/MyLib.dylib")]
)

I try to add LD_RUNPATH_SEARCH_PATHS to FooBarTests.scheme, but nothing changed and target can't be tested, because MyLib.dylib can't be found at @runpath.

FooBarTests.scheme

EnvironmentVariable:

LD_RUNPATH_SEARCH_PATHS=$(inherited) @loader_path/../Resources
LIBRARY_SEARCH_PATHS=$(inherited) Resources/MyLib.dylib
1 Like