hassila
(Joakim Hassila)
December 29, 2024, 7:51am
64
We do actually use dynamic libraries on linux, but we can guarantee an exact same build and deployment environment and have to use a (minimally) patched swiftpm currently - far from ideal and not practical for most.
Some relevant open issues/pull requests for more generic linux support:
opened 10:45AM - 09 Aug 22 UTC
enhancement
### Description
# Background
We have an enterprise-style application where we … have a large number of libraries (swift packages) that we'd like to be able to evolve independently using library evolution and to dynamically link them to a large number of consumers.
Basically adding binary dependency support to a dynamic library generated using SPM similar to XCFrameworks.
I've read https://github.com/apple/swift-evolution/blob/main/proposals/0305-swiftpm-binary-target-improvements.md and would like to suggest a first step could be to cater to this kind of 'enterprise' deployment scenario rather than taking on the full 'many linuxes support everywhere' - we have full control over deployment operating system and swift toolchain (we can mandate for our customers what they must have to run the software and would do builds for a small number of deployment environments that we support).
The artefact bundle format seems that it would suffice for such a scenario.
So trying to break down what's needed (perhaps missing something):
- Support for binary dependencies also for Linux (preferably using `artifactbundle` format so we can have both macOS and Linux in a single dependency if putting things in the right places)
- Support for enabling library evolution for SPM packages generating dynamic libraries on both macOS and Linux (accepting the requirement for same toolchain on Linux)
I think this single-linux-distribution as a first step could be very useful not only for us, but also for others - and help as a stopgap deployment measure.
See also related discussions / issues:
https://github.com/apple/swift/issues/60458
https://forums.swift.org/t/use-a-dynamic-library-in-a-swift-package-on-linux/59510
https://forums.swift.org/t/availability-when-using-library-evolution-resilience-for-third-party-libraries/59341/3
etc.
Also recently added:
https://github.com/apple/swift/issues/66156
### Expected behavior
_No response_
### Actual behavior
_No response_
### Steps to reproduce
_No response_
### Swift Package Manager version/commit hash
_No response_
### Swift & OS version (output of `swift --version && uname -a`)
_No response_
swiftlang:main
← swiftlang:maxd/library-artifact-bundle
opened 10:02PM - 03 Oct 23 UTC
opened 02:17AM - 25 Oct 23 UTC
enhancement
### Description
Binary targets are a vital part of the SwiftPM ecosystem and cu… rrently any discussions about extending the format or expanding usage of this format (or xcframeworks) in general are limited due to the packaging tool being included as part of xcodebuild. Interestingly, computing the checksum for a binary target is included as part of the `swift package` suite of tools, but not the creation of said package.
I believe migrating this functionality from xcodebuild to SwiftPM would be advantageous as it could open up discussions to make SwiftPM even more useful on non-Darwin platforms that want to use Swift.
### Expected behavior
I'd like to write something like the following:
`swift package create-xcframework -framework <path> [-framework <path>...] -output <path> `
or
`swift package -create-xcframework -library <path> [-headers <path>] [-library <path> [-headers <path>]...] -output <path>`
Which would create the framework similarly as it does when running the command from `xcodebuild`
### Actual behavior
This command doesn't exist today and you're forced to run `xcodebuild -create-xcframework` on macOS.
### Steps to reproduce
1. Launch a Linux or Windows installation that has Swift installed
2. Attempt to run either `xcodebuild -create-xcframework ...` or `swift package create-xcframework ...` and see that it doesn't work
### Swift Package Manager version/commit hash
Swift Package Manager - Swift 5.9.0
### Swift & OS version (output of `swift --version && uname -a`)
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
Darwin zerocool.localdomain 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 arm64
8 Likes