I have an Xcode Swift project that depends on OpenSSL. (It clones the repo and calls a build script to produce binary then copies a custom module map file.)
Is there a way to add an external build target (following the standard Configure, make, make install) as a dependency in SwifPM? If we could do this, a lot of open source C projects would be easily converted and being used in Swift.
No. (Not yet at least.)
But that doesn’t mean you cannot use open source C libraries. I usually:
- Fork the C repository.
- Branch from a release version.
- Generate any normally transient files and check them in.
- Add a
- Tag a semantic version (on the fork).
- Declare the fork package as a dependency.
- (Optional) Pester the upstream repository to start providing the
Thanks for your reply, Jeremy. I'd rather stick with Xcode for now.
Just an idea: For SwiftPM and Swift to attract more users, I guess we needs to absorb the standard way of compilation and CMake.
OpenSSL has hundreds of .c files. Depending on the configuration, many .c files are not included in the compilation. It's not trivial to tell Clang how to compile for various platforms and configurations correctly. Even if I took time to configure for macOS now, I'd have to maintain the modification with OpenSSL evolution. it'll be nice if we could just "steal" the good things that people has been doing and put into SwiftPM.
Remember at some points, Julia did some really good things. Python just steals and puts in a C library called import Julia. This is how Python tends to destroy these poor little things before they had a chance to grow and how it gets those smart people in Ruby and other languages into the Python community.
I really think Swift is great because it works so well with Objective-C and C. It gives us a much better way of doing old things. Hope we'll steal CMake into SwiftPM.
I answered your question according to the present state of things, but since you are now talking about your hopes for the future of the package manager, you might also want to take a look at this thread:
Thank you, @lpham, for your question & idea and, @SDGGiesbrecht, for your answers. I have a similar suggestion, and I didn't really understand that draft proposal, so I added a new feature request: Let me add package dependencies that use CMake.
Awesome feature request, Matthew! I'm sure it'll make Swift a much more attractive language.
Thank you, @lpham! :-) Yes, certainly it would for me.