Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keith/StaticInternalSwiftSyntaxParser
A static library for using SwiftSyntax / lib_InternalSwiftSyntaxParser
https://github.com/keith/StaticInternalSwiftSyntaxParser
Last synced: 3 months ago
JSON representation
A static library for using SwiftSyntax / lib_InternalSwiftSyntaxParser
- Host: GitHub
- URL: https://github.com/keith/StaticInternalSwiftSyntaxParser
- Owner: keith
- License: mit
- Archived: true
- Created: 2022-01-27T05:36:55.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-17T23:12:40.000Z (over 1 year ago)
- Last Synced: 2024-07-19T02:12:44.953Z (4 months ago)
- Language: Shell
- Size: 7.81 KB
- Stars: 48
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StaticInternalSwiftSyntaxParser
NOTE: As of Swift 5.8 this library is no more, instead it has been
reimplemented in Swift as part of
[`SwiftSyntax`](https://github.com/apple/swift-syntax)This is a distribution of `lib_InternalSwiftSyntaxParser.dylib` built
statically. This allows you to create a self contained portable binary
that depends on [`swift-syntax`][swift-syntax] instead of having to
depend on your specific Xcode version and path, or distribute the
library alongside your tool.# Usage
See [the releases
page](https://github.com/keith/StaticInternalSwiftSyntaxParser/releases)
to get the right version of the library for your version of Xcode and
[`swift-syntax`][swift-syntax].With Swift Package Manager you can use the `.binaryTarget` type with
this:```swift
targets: [
// Some targets
.binaryTarget(
name: "lib_InternalSwiftSyntaxParser",
url: "See releases page",
checksum: "See releases page"
),
],
```Then add `lib_InternalSwiftSyntaxParser` to the `dependencies` of
another target.If you want to use this without Swift Package Manager you can download
the xcframework and use the internal
`lib_InternalSwiftSyntaxParser.framework` however you'd normally include
dependencies.Note: because of [this bug](https://bugs.swift.org/browse/SR-15802) if
you want to depend on this target in SwiftPM and target multiple
architectures in a single build, you must only depend on it from top
level targets such as a test or executable target.## Building
To create a new release for this project follow these steps:
- Clone [`apple/swift`](https://github.com/apple/swift) and checkout the
branch you want using the `update-checkout` script as described in
their documentation
- Cherry pick the most recent commit from the releases page, or use the
`example.patch` checked into this repo as a starting point
- Build the project with something like `./swift/utils/build-script
--release`
- If you'd like a fat binary for supporting arm64 and x86_64 macs, build
with `./swift/utils/build-script --release --cross-compile-hosts
macosx-x86_64`
- Run `create-xcframework.sh swift/src/dir binary1 binary2` to create
the combined framework## Notes
- This method doesn't actually produce a static binary, but it produces
a relocatable object file which is similar enough for this use case.
This is because cmake cannot create distributable static library
targets that include all of their nested dependencies
- Be sure to pass `-dead_strip` to your linker when linking this library
with a binary to save on binary size (you likely already are)
- As of Swift 5.6 Apple bundles a dynamic version of this library as part
of the SwiftSyntax release. In order to ignore that version and prefer
this static version, you must pass `-Xlinker -dead_strip_dylibs` when
building your tool. This can be done by adding it to the `linkerSettings`
of the target that depends on this library in your Package.swift file.[swift-syntax]: https://github.com/apple/swift-syntax