Skip to content

Commit 1324a65

Browse files
committed
[Readme] Update Readme to mention how to embed the parser library and how to build it for iOS
1 parent efd4256 commit 1324a65

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ should be specified with the intended tag.
7979
Different from building SwiftSyntax from source, declaring SwiftSyntax as a SwiftPM dependency doesn't require
8080
the Swift compiler source because we always push gyb-generated files to a tag.
8181

82+
### Embedding SwiftSyntax in an Application
83+
84+
SwiftSyntax depends on the `lib_InternalSwiftSyntaxParser.dylib/.so` library which provides a C interface to the underlying Swift C++ parser. When you do `swift build` SwiftSyntax links and uses the library included in the Swift toolchain. If you are building an application make sure to embed `_InternalSwiftSyntaxParser` as part of your application's libraries.
85+
86+
You can either copy `lib_InternalSwiftSyntaxParser.dylib/.so` directly from the toolchain or even build it yourself from the [Swift repository](https://github.com/apple/swift), as long as you are matching the same tags or branches in both the SwiftSyntax and Swift repositories. To build it for the host os (macOS/linux) use the following steps:
87+
88+
```
89+
git clone https://github.com/apple/swift.git
90+
./swift/utils/update-checkout --clone
91+
./swift/utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build
92+
```
93+
94+
### Embedding in an iOS Application
95+
96+
You need to build `lib_InternalSwiftSyntaxParser.dylib` yourself, you cannot copy it from the toolchain. Follow the instructions above and change the invocation of `build-parser-lib` accordingly:
97+
98+
```
99+
./swift/utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build-iossim --host iphonesimulator --architectures x86_64
100+
./swift/utils/build-parser-lib --release --no-assertions --build-dir /tmp/parser-lib-build-ios --host iphoneos --architectures arm64
101+
```
102+
82103
### Some Example Users
83104

84105
[**Swift AST Explorer**](https://swift-ast-explorer.kishikawakatsumi.com/): a Swift AST visualizer.

0 commit comments

Comments
 (0)