Swiftpack.co -  minikin/ItemsDataSource as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
:recycle: Generic datasource for UICollectionView
.package(url: "https://github.com/minikin/ItemsDataSource.git", from: "0.2.0")


Build Status CocoaPods Platform

ItemsDataSource is a generic datasource for UICollectionView.


  • Create collections with any data types
  • Reusable UICollectionViewCell and UICollectionReusableView
  • UICollectionView at its core
  • Easy extendable


  • iOS 10.0+
  • Xcode 9.0+
  • Swift 5.0+



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1+ is required to build ItemsDataSource.

To integrate ItemsDataSource into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target '<Your Target Name>' do
    pod 'ItemsDataSource'

if you're using CocoaPods 1.5.0+ you can include ItemsDataSource as static library:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'

target '<Your Target Name>' do
    pod 'ItemsDataSource'

Then, run the following command:

$ pod install


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate ItemsDataSource into your Xcode project using Carthage, specify it in your Cartfile:

github "ItemsDataSource"

Run carthage update to build the framework and drag the built ItemsDataSource.framework into your Xcode project.


If you prefer not to use any of the aforementioned dependency managers, you can integrate ItemsDataSource into your project manually. Just copy files from Sources folder to your projects:



Define your model as usual

import UIKit
import ItemsDataSource

struct Vitamin {

  // MARK: - Instance Properties

  let name: String
  let amount: Double

Conform your model to Itemable

extension Vitamin: Itemable {
  var itemCellDescriptor: CellDescriptor {
    return CellDescriptor(reuseIdentifier: ReuseIdentifier.vitaminCell, configure: configureIngredientCell)

Add configure method to model in extension

extension Vitamin {
  func configureIngredientCell(_ cell: ViataminCell) {
    cell.vitaminNameLabel.text = name
    cell.backgroundColor = UIColor.randomColor()

In ViewController inject your datasource

import ItemsDataSource
import UIKit

final class ExampleViewController: UIViewController {

  // MARK: - Injections

  public var vitaminsDataSourse = ItemsDataSource(items: [Vitamin](https://raw.github.com/minikin/ItemsDataSource/master/),
                                                  cellDescriptor: { $0.itemCellDescriptor })

  // MARK: - IBOutlets

  @IBOutlet var exampleCollectionView: UICollectionView! {
    didSet {
      exampleCollectionView.delegate = self

  // MARK: - Instance Properties

  var vitamins = [Vitamin](https://raw.github.com/minikin/ItemsDataSource/master/)

  // MARK: - ViewController LifeCycle

  override func viewDidLoad() {
    print("vitamins", vitamins)

  // MARK: - Helpers

  private func setExampleCollectionViewDataSource() {
    vitaminsDataSourse.items = vitamins
    exampleCollectionView.dataSource = vitaminsDataSourse

  private func setExampleCollectionViewLayout() {
    let layout = CommonFlowLayout(columns: 2,
                                  itemHeight: 200,
                                  inset: 5,
                                  spacing: 0,
                                  lineSpacing: 5)
    exampleCollectionView.collectionViewLayout = layout

// MARK: - UICollectionViewDelegate

extension ExampleViewController: UICollectionViewDelegate {}

For more details, please check an iOS example or ask me on twitter: @minikin


Post issues and feature requests on the GitHub issue tracker.


ItemsDataSource is released under the MIT license. See LICENSE for details.


Stars: 9
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Swift 5 Update
2 years ago
  • Update project to Swift 5
  • Minor updates

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics