Swift Package for Decoding RSS Feeds.

Overview

SyndiKit

SyndiKit

Swift Package built on top of XMLCoder for Decoding RSS Feeds. Check out the DocC-Built Site!

DocC

Twitter GitHub SyndiKit GitHub issues

Codecov CodeFactor codebeat badge Code Climate maintainability Code Climate technical debt Code Climate issues Reviewed by Hound

Table of Contents

Introduction

Built on top of XMLCoder by Max Desiatov, 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 11.4.1 or later
  • Swift 5.2.4 or later
  • iOS 9.0 / watchOS 2.0 / tvOS 9.0 / macOS 10.10 or later deployment targets

Linux

  • Ubuntu 18.04 or later
  • Swift 5.2.4 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:

let package = Package(
  ...
  dependencies: [
    .package(url: "https://github.com/brightdigit/SyndiKit", from: "0.1.0")
  ],
  targets: [
      .target(
          name: "YourTarget",
          dependencies: ["SyndiKit", ...]),
      ...
  ]
)

If this is for an Xcode project simply import the repo at:

https://github.com/brightdigit/SyndiKit

Usage

SyndiKit 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(_:):

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.

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:

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.

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

The DocC official web site is at syndikit.dev. This includes tutorials, articles, code documentation and more.

GitHub SourceDocs

For just markdown formatted documentation on GitHub using SourceDocs, you can read see the list of types here.

Roadmap

1.0.0

  • OPML Support
  • WordPress DocC Tutorial
  • RSS Import Tutorial (i.e. OrchardNest)

License

This code is distributed under the MIT license. See the LICENSE file for more info.

You might also like...
Azure Maps iOS SDK binary distribution for Swift Package Manager
Azure Maps iOS SDK binary distribution for Swift Package Manager

Azure Maps Control for iOS Installation In your Xcode iOS Project settings, under Project setting’s Package Dependencies, click on + button to add pac

Numerals is a package containing additional numeric types for the Swift programming language.

swift-numerals Numerals is a package containing additional numeric types for the Swift programming language. Contents The package currently provides t

Swift package adding fraction and percentage types.

swift-rationals Rationals is a package containing Fraction and Percentage types for the Swift programming language. Contents The package currently pro

Swift package adding measurable types.

swift-measures Measures is a package containing measurable types for the Swift programming language. Contents The package currently provides the follo

Swift package for accessing SF Symbols in a type safe manner.

Swift Package Information Code Coverage Swift package for accessing SF Symbols in a type safe manner. Features 💫 Contains all SF Symbols - 1.0, 2.0,

This is a Swift package with support for macOS that allows to start Java Jar's with the default or a custom JVM.

Jar.swift jar runner for macos Jar.swift is created and maintaned with ❥ by Sascha Muellner. What? This is a Swift package with support for macOS that

Units is a Swift package to manipulate, compare, and convert between physical quantities.

Units 📏 Units is a Swift package to manipulate, compare, and convert between physical quantities. This package models measurements, which are a numer

 WWDCKit - Creating and Using a Swift Package
WWDCKit - Creating and Using a Swift Package

WWDCKit - Creating and Using a Swift Package 1. Create the Package in Xcode Navigate to File New Package. Give the Package a name e.g "WWDCKit".

Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types
Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types

Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types

Comments
  • Problems with RSS from some major news cooperations

    Problems with RSS from some major news cooperations

    I tried out SyndiKit in my app, where I want to parse the RSS feed from CNN and the national Danish broadcasting company 'DR'. Both fail. When I try an RSS feed from the national Swedish broadcasting company 'SVT', it works fine.

    I can't seem to figure out, what the difference is, that makes CNN and DR fail.

    The failing RSS feeds:

    • http://rss.cnn.com/rss/cnn_latest.rss
    • https://www.dr.dk/nyheder/service/feeds/senestenyt

    The working RSS feed:

    • https://www.svt.se/rss.xml
    opened by MortenGregersen 6
Releases(0.3.1)
  • 0.3.1(Dec 5, 2022)

    What's Changed

    • Update README.md by @leogdion in https://github.com/brightdigit/SyndiKit/pull/39
    • making itunes owner email optional by @leogdion in https://github.com/brightdigit/SyndiKit/pull/41

    Full Changelog: https://github.com/brightdigit/SyndiKit/compare/0.3.0...0.3.1

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Nov 18, 2022)

    What's Changed

    • Fixing Issue #35
    • Upgrade Swift Version from 5.5 - 5.7.1

    Full Changelog: https://github.com/brightdigit/SyndiKit/compare/0.2.0...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Nov 30, 2021)

    What's Changed

    • Update Enclosure.swift to allow public access by @leogdion in https://github.com/brightdigit/SyndiKit/pull/31
    • Updated GitHub Action Swift Download URL for Ubuntu Full Changelog: https://github.com/brightdigit/SyndiKit/compare/0.1.2...0.1.3
    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Oct 25, 2021)

Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS.

CBORCoding CBORCoding is a lightweight framework containing a coder pair for encoding and decoding Codable conforming types to and from CBOR document

Joe Newton 23 Nov 8, 2022
Swift Package Manager plugin which runs ActionBuilder to create a Github Actions workflow for a swift package.

ActionBuilderPlugin A Swift Package Manager command which builds a Github Actions workflow for the current package. By default the workflow file will

Elegant Chaos 4 Jul 20, 2022
Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Apple 2k Dec 28, 2022
Approximate is a Swift package that provides implementations of floating point comparisons for the Swift ecosystem

Approximate Approximate floating point equality comparisons for the Swift Programming Language. Introduction Approximate is a Swift package that provi

Christopher Blanchard 1 Jun 1, 2022
A simple swift package that provides a Swift Concurrency equivalent to `@Published`.

AsyncValue This is a simple package that provides a convenience property wrapper around AsyncStream that behaves almost identically to @Published. Ins

Brent Mifsud 33 Oct 3, 2022
A command-line tool and Swift Package for generating class diagrams powered by PlantUML

SwiftPlantUML Generate UML class diagrams from swift code with this Command Line Interface (CLI) and Swift Package. Use one or more Swift files as inp

null 374 Jan 3, 2023
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

Zamzam Inc. 261 Dec 15, 2022
Swift implementation of the package url spec

PackageURL Swift implementation of the package url specification. Requirements Swift 5.3+ Usage import PackageURL let purl: PackageURL = "pkg:swift/a

Mattt 21 Jun 14, 2022
Mechanical editing support for Package.swift manifests

Mechanical editing support for Package.swift manifests. Implements Swift Evolution proposal SE-301

Owen Voorhees 9 Jan 4, 2023
A simple Swift package for counting the Syllables in a sentence.

A simple Swift package for counting the Syllables in a sentence.

null 2 Jan 3, 2022