PackageConfig lib linking issue
Hi,
Thank you for this great library! I've start using it recently and I came across a small problem.
The library looks by default in the .build folder for the libPackageConfig.
So, when I run the following on my package, for example:
swift build && cd .build/debug/ && ./my-executable
The result is that it cannot find the .build folder. The same happens when moving the binary in the /usr/local/bin path, which sort of make it un-usable together with Mint
Is there any plan to overcome this issue? Is it even considered as an issue? Thank you very much
I think it could look in a few different folders for a build directory (we did that with danger-swift for example)
I'd consider it an issue, they probably hardcode those build folders so can just make a list and look there?
This wouldn’t work in case PackageConfig is included as a dependency in the Package file. So would you recommend to install PackageConfig globally using mint, for example?
On the same note, what I would expect from most of the people are the below steps:
- Import PackageConfig as a dependency of their executable
- Build the executable on top of that (and somewhere try to call
getPackageConfig()) - Take the executable binary and move it to a different folder (ex:
/usr/local/) - When launching the executable, that would crash because the lib couldn't be found.
@dalu93 think i have an idea on how to make it work almost as you specified. https://github.com/shibapm/PackageConfig/blob/33ea88fdfacf2350cbe34ea5cac7750b2ebfe2f7/Sources/PackageConfig/PackageConfig.swift#L18 https://github.com/shibapm/PackageConfig/blob/33ea88fdfacf2350cbe34ea5cac7750b2ebfe2f7/Sources/PackageConfig/Writer.swift#L8 https://github.com/shibapm/PackageConfig/blob/33ea88fdfacf2350cbe34ea5cac7750b2ebfe2f7/Sources/PackageConfig/PackageConfig.swift#L17 I think modifying these methods to accept a list of path to search for dynamic libraries at run would suffice. So that a library user would define search path for a dynamic library in the config as follows.
#if canImport(ExampleConfig)
import ExampleConfig
ExampleConfig(value: "example value").write(searchPaths: ["/usr/local/", ".build/debug", ])
#endif
Would try to implement when i have time. This would allow PackageConfig to also be installed system wide.