Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apple/pkl-swift-examples
Examples for using Pkl within Swift applications
https://github.com/apple/pkl-swift-examples
Last synced: 27 days ago
JSON representation
Examples for using Pkl within Swift applications
- Host: GitHub
- URL: https://github.com/apple/pkl-swift-examples
- Owner: apple
- License: apache-2.0
- Created: 2024-01-26T15:24:47.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-14T13:15:28.000Z (7 months ago)
- Last Synced: 2024-09-29T21:41:23.167Z (about 1 month ago)
- Language: Swift
- Homepage:
- Size: 15.6 KB
- Stars: 78
- Watchers: 11
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- Contributing: CONTRIBUTING.adoc
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.adoc
- Security: SECURITY.adoc
Awesome Lists containing this project
README
= pkl-swift-example
This is a sample project that demonstrates Pkl <> Swift integration.
This is a basic HTTP server that is configured via Pkl in the `pkl/` directory.
== Requirements
* Swift +5.9
* Pkl +0.25.0== Project structure
[cols="1,1"]
|===
| Directory
| Description| `pkl/`
| Pkl configuration sources| `Sources/Gen/`
| Generated Swift sources from Pkl| `Sources/App/`
| Swift files
|===== Codegen
Generated sources are already checked into git for learning purposes.
To generate new Pkl sources, first install the Swift code generator:
[source,bash]
----
curl https://github.com/apple/pkl-swift/releases/download/0.2.0/pkl-gen-swift-macos.bin -o pkl-gen-swift
chmod +x pkl-gen-swift
----With that installed, generate Swift sources via:
[source,bash]
----
pkl-gen-swift pkl/**.pkl -o Sources/Gen
----== Running the server
To run the project call `swift run`.