https://github.com/brightdigit/syndikit
Swift Package for Decoding RSS Feeds.
https://github.com/brightdigit/syndikit
rss swift swiftpackagemanager
Last synced: 7 days ago
JSON representation
Swift Package for Decoding RSS Feeds.
- Host: GitHub
- URL: https://github.com/brightdigit/syndikit
- Owner: brightdigit
- License: mit
- Created: 2021-06-21T13:22:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-26T13:52:17.000Z (over 1 year ago)
- Last Synced: 2025-04-01T09:47:12.791Z (27 days ago)
- Topics: rss, swift, swiftpackagemanager
- Language: Swift
- Homepage: https://syndikit.work
- Size: 7.28 MB
- Stars: 61
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
SyndiKit
Swift Package built on top of [XMLCoder](https://github.com/CoreOffice/XMLCoder) for Decoding RSS Feeds. Check out the [DocC-Built Site!](https://syndikit.dev/)
[](https://swiftpackageindex.com/brightdigit/SyndiKit)
[](https://swiftpackageindex.com/brightdigit/SyndiKit)
[](https://syndikit.dev/)[](http://twitter.com/brightdigit)

[](https://github.com/brightdigit/SyndiKit/actions/workflows/syndikit.yml)
[](https://codecov.io/gh/brightdigit/SyndiKit)
[](https://www.codefactor.io/repository/github/brightdigit/syndikit)
[](https://codebeat.co/projects/github-com-brightdigit-syndikit-main)
[](https://codeclimate.com/github/brightdigit/SyndiKit)
[](https://codeclimate.com/github/brightdigit/SyndiKit)
[](https://codeclimate.com/github/brightdigit/SyndiKit)
[](https://houndci.com)## Table of Contents
* [Introduction](#introduction)
* [Features](#features)
* [Installation](#installation)
* [Requirements](#requirements)
* [Swift Package Manager](#swift-package-manager)
* [Usage](#usage)
* [Decoding Your First Feed](#decoding-your-first-feed)
* [Working with Abstractions](#working-with-abstractions)
* [Specifying Formats](#specifying-formats)
* [Accessing Extensions](#accessing-extensions)
* [Documentation](#documentation)
* [DocC](https://syndikit.dev)
* [GitHub SourceDocs](/Documentation/Reference/SyndiKit/README.md)
* [Roadmap](#roadmap)
* [License](#license)## Introduction
Built on top of [XMLCoder](https://github.com/CoreOffice/XMLCoder), SyndiKit can be used to import and read site data whether from a WordPress site, RSS feeds, YouTube channel or podcast.
## Features
* Import of RSS 2.0, Atom, and JSONFeed formats
* Extensions for iTunes-compatabile podcasts, YouTube channels, as well as WordPress export data
* User-friendly errors
* Abstractions for format-agnostic parsing## Installation
### Requirements
**Apple Platforms**
- Xcode 13.3 or later
- Swift 5.5.2 or later
- iOS 15.4 / watchOS 8.5 / tvOS 15.4 / macOS 12.3 or later deployment targets**Linux**
- Ubuntu 18.04 or later
- Swift 5.5.2 or later### Swift Package Manager
Swift Package Manager is Apple's decentralized dependency manager to integrate libraries to your Swift projects. It is now fully integrated with Xcode 11.
To integrate **SyndiKit** into your project using SPM, specify it in your Package.swift file:
```swift
let package = Package(
...
dependencies: [
.package(url: "https://github.com/brightdigit/SyndiKit", from: "0.3.0")
],
targets: [
.target(
name: "YourTarget",
dependencies: ["SyndiKit", ...]),
...
]
)
```If this is for an Xcode project simply import the repo at:
```
https://github.com/brightdigit/SyndiKit
```
## UsageSyndiKit provides models and utilities for decoding RSS feeds of various formats and extensions.
### Decoding Your First Feed
You can get started decoding your feed by creating your first ``SynDecoder``. Once you've created you decoder you can decode using ``SynDecoder/decode(_:)``:
```swift
let decoder = SynDecoder()
let empowerAppsData = Data(contentsOf: "empowerapps-show.xml")!
let empowerAppsRSSFeed = try decoder.decode(empowerAppsData)
```### Working with Abstractions
Rather than working directly with the various formats, **SyndiKit** abstracts many of the common properties of the various formats. This enables developers to be agnostic regarding the specific format.
```swift
let decoder = SynDecoder()// decoding a RSS 2.0 feed
let empowerAppsData = Data(contentsOf: "empowerapps-show.xml")!
let empowerAppsRSSFeed = try decoder.decode(empowerAppsData)
print(empowerAppsRSSFeed.title) // Prints "Empower Apps"// decoding a Atom feed from YouTube
let kiloLocoData = Data(contentsOf: "kilo.youtube.xml")!
let kiloLocoAtomFeed = try decoder.decode(kiloLocoData)
print(kiloLocoAtomFeed.title) // Prints "Kilo Loco"
```### Specifying Formats
If you wish to access properties of specific formats, you can attempt to cast the objects to see if they match:
```swift
let empowerAppsRSSFeed = try decoder.decode(empowerAppsData)
if let rssFeed = empowerAppsRSSFeed as? RSSFeed {
print(rssFeed.channel.title) // Prints "Empower Apps"
}let kiloLocoAtomFeed = try decoder.decode(kiloLocoData)
if let atomFeed = kiloLocoAtomFeed as? AtomFeed {
print(atomFeed.title) // Prints "Empower Apps"
}
```### Accessing Extensions
In addition to supporting RSS, Atom, and JSONFeed, **SyndiKit** also supports various RSS extensions for specific media including: YouTube, iTunes, and WordPress.
You can access these properties via their specific feed formats or via the ``Entryable/media`` property on ``Entryable``.
```swift
let empowerAppsRSSFeed = try decoder.decode(empowerAppsData)
switch empowerAppsRSSFeed.children.last?.media {
case .podcast(let podcast):
print(podcast.title) // print "WWDC 2018 - What Does It Mean For Businesses?"
default:
print("Not a Podcast! 🤷♂️")
}let kiloLocoAtomFeed = try decoder.decode(kiloLocoData)
switch kiloLocoAtomFeed.children.last?.media {
case .video(.youtube(let youtube):
print(youtube.videoID) // print "SBJFl-3wqx8"
print(youtube.channelID) // print "UCv75sKQFFIenWHrprnrR9aA"
default:
print("Not a Youtube Video! 🤷♂️")
}
```## Documentation
There are two formats for the source documentation:
### [DocC](https://syndikit.dev)
[The **DocC** official web site is at syndikit.dev.](https://syndikit.dev) This includes tutorials, articles, code documentation and more.
### [GitHub SourceDocs](/Documentation/Reference/SyndiKit/README.md)
For just markdown formatted documentation on GitHub using [SourceDocs](https://github.com/eneko/SourceDocs), you can read see [the list of types here.](/Documentation/Reference/SyndiKit/README.md)
## Roadmap
## 1.0.0
- [ ] OPML Support
- [ ] WordPress DocC Tutorial
- [ ] RSS Import Tutorial (i.e. [OrchardNest](https://orchardnest.com))## License
This code is distributed under the MIT license. See the [LICENSE](LICENSE) file for more info.