PackageConfig icon indicating copy to clipboard operation
PackageConfig copied to clipboard

PackageConfig lib linking issue

Open dalu93 opened this issue 6 years ago • 4 comments

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

dalu93 avatar Jan 17 '19 18:01 dalu93

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?

orta avatar Jan 17 '19 18:01 orta

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?

dalu93 avatar Jan 17 '19 20:01 dalu93

On the same note, what I would expect from most of the people are the below steps:

  1. Import PackageConfig as a dependency of their executable
  2. Build the executable on top of that (and somewhere try to call getPackageConfig())
  3. Take the executable binary and move it to a different folder (ex: /usr/local/)
  4. When launching the executable, that would crash because the lib couldn't be found.

dalu93 avatar Jan 18 '19 08:01 dalu93

@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.

IgorMuzyka avatar Jul 24 '19 23:07 IgorMuzyka