From 7e0b943664779406d5b90df3f69e83ef7b36c3b2 Mon Sep 17 00:00:00 2001
From: Benoit Layer <1849419+notbenoit@users.noreply.github.com>
Date: Thu, 17 Feb 2022 12:07:37 +0100
Subject: [PATCH] refactor(spm): add spm support
---
.gitignore | 2 ++
.../CollectionView/CollectionViewCell.swift | 2 ++
.../CollectionViewChangeTarget.swift | 2 ++
.../CollectionViewDataSource.swift | 2 ++
.../CollectionViewReusableView.swift | 2 ++
DataSource/DataSourceCellDescriptor.swift | 2 ++
DataSource/Info.plist | 2 +-
DataSource/TableView/TableViewCell.swift | 2 ++
.../TableView/TableViewChangeTarget.swift | 2 ++
.../TableView/TableViewDataSource.swift | 2 ++
...ViewDataSourceWithHeaderFooterTitles.swift | 2 ++
...eViewDataSourceWithHeaderFooterViews.swift | 2 ++
.../TableView/TableViewHeaderFooterView.swift | 2 ++
Package.swift | 29 +++++++++++++++++++
14 files changed, 54 insertions(+), 1 deletion(-)
create mode 100644 Package.swift
diff --git a/.gitignore b/.gitignore
index 34fc180..c3e97a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
xcuserdata
*.xccheckout
Carthage/Build
+.build
+.swiftpm
diff --git a/DataSource/CollectionView/CollectionViewCell.swift b/DataSource/CollectionView/CollectionViewCell.swift
index 0d3a717..4a71492 100644
--- a/DataSource/CollectionView/CollectionViewCell.swift
+++ b/DataSource/CollectionView/CollectionViewCell.swift
@@ -7,6 +7,7 @@
//
import Combine
+#if canImport(UIKit)
import UIKit
/// `UICollectionViewCell` subclass that implements `DataSourceItemReceiver` protocol
@@ -23,3 +24,4 @@ open class CollectionViewCell: UICollectionViewCell, DataSourceItemReceiver {
self.cellModel.value = item
}
}
+#endif
diff --git a/DataSource/CollectionView/CollectionViewChangeTarget.swift b/DataSource/CollectionView/CollectionViewChangeTarget.swift
index bbef6a8..c7a34a5 100644
--- a/DataSource/CollectionView/CollectionViewChangeTarget.swift
+++ b/DataSource/CollectionView/CollectionViewChangeTarget.swift
@@ -7,6 +7,7 @@
//
import Foundation
+#if canImport(UIKit)
import UIKit
extension UICollectionView: DataChangeTarget {
@@ -50,3 +51,4 @@ extension UICollectionView: DataChangeTarget {
self.reloadSections(IndexSet(dsIntegers: sections))
}
}
+#endif
diff --git a/DataSource/CollectionView/CollectionViewDataSource.swift b/DataSource/CollectionView/CollectionViewDataSource.swift
index f02a500..d0dd6cf 100644
--- a/DataSource/CollectionView/CollectionViewDataSource.swift
+++ b/DataSource/CollectionView/CollectionViewDataSource.swift
@@ -8,6 +8,7 @@
import Combine
import Foundation
+#if canImport(UIKit)
import UIKit
/// An object that implements `UICollectionViewDataSource` protocol
@@ -104,3 +105,4 @@ open class CollectionViewDataSource: NSObject, UICollectionViewDataSource {
return cell
}
}
+#endif
diff --git a/DataSource/CollectionView/CollectionViewReusableView.swift b/DataSource/CollectionView/CollectionViewReusableView.swift
index 6e07750..2ee46a1 100644
--- a/DataSource/CollectionView/CollectionViewReusableView.swift
+++ b/DataSource/CollectionView/CollectionViewReusableView.swift
@@ -7,6 +7,7 @@
//
import Combine
+#if canImport(UIKit)
import UIKit
/// `UICollectionReusableView` subclass that implements `DataSourceItemReceiver` protocol
@@ -23,3 +24,4 @@ open class CollectionViewReusableView: UICollectionReusableView, DataSourceItemR
self.viewModel.value = item
}
}
+#endif
diff --git a/DataSource/DataSourceCellDescriptor.swift b/DataSource/DataSourceCellDescriptor.swift
index 0504b7c..29f8909 100644
--- a/DataSource/DataSourceCellDescriptor.swift
+++ b/DataSource/DataSourceCellDescriptor.swift
@@ -6,6 +6,7 @@
// Copyright © 2019 Fueled. All rights reserved.
//
+#if canImport(UIKit)
import UIKit
public class CellDescriptor: NSObject {
@@ -189,3 +190,4 @@ extension ReusableItem where Self: UIView {
extension ReusableNib where Self: UIView, Self: ReusableItem {
public static var nib: UINib { return UINib(nibName: self.reuseIdentifier, bundle: nil) }
}
+#endif
diff --git a/DataSource/Info.plist b/DataSource/Info.plist
index 8023c0f..a847c39 100644
--- a/DataSource/Info.plist
+++ b/DataSource/Info.plist
@@ -21,7 +21,7 @@
CFBundleVersion
$(CURRENT_PROJECT_VERSION)
NSHumanReadableCopyright
- Copyright © 2015 Fueled. All rights reserved.
+ Copyright © 2022 Fueled. All rights reserved.
NSPrincipalClass
diff --git a/DataSource/TableView/TableViewCell.swift b/DataSource/TableView/TableViewCell.swift
index 3932cd0..54c6c30 100644
--- a/DataSource/TableView/TableViewCell.swift
+++ b/DataSource/TableView/TableViewCell.swift
@@ -7,6 +7,7 @@
//
import Combine
+#if canImport(UIKit)
import UIKit
/// `UITableViewCell` subclass that implements `DataSourceItemReceiver` protocol
@@ -23,3 +24,4 @@ open class TableViewCell: UITableViewCell, DataSourceItemReceiver {
self.cellModel.value = item
}
}
+#endif
diff --git a/DataSource/TableView/TableViewChangeTarget.swift b/DataSource/TableView/TableViewChangeTarget.swift
index 965a9af..f03fb39 100644
--- a/DataSource/TableView/TableViewChangeTarget.swift
+++ b/DataSource/TableView/TableViewChangeTarget.swift
@@ -7,6 +7,7 @@
//
import Foundation
+#if canImport(UIKit)
import UIKit
extension UITableView: DataChangeTarget {
@@ -53,3 +54,4 @@ extension UITableView: DataChangeTarget {
self.reloadSections(IndexSet(dsIntegers: sections), with: .fade)
}
}
+#endif
diff --git a/DataSource/TableView/TableViewDataSource.swift b/DataSource/TableView/TableViewDataSource.swift
index 39d75d2..25a7582 100644
--- a/DataSource/TableView/TableViewDataSource.swift
+++ b/DataSource/TableView/TableViewDataSource.swift
@@ -8,6 +8,7 @@
import Combine
import Foundation
+#if canImport(UIKit)
import UIKit
/// An object that implements `UITableViewDataSource` protocol
@@ -91,3 +92,4 @@ open class TableViewDataSource: NSObject, UITableViewDataSource {
return cell
}
}
+#endif
diff --git a/DataSource/TableView/TableViewDataSourceWithHeaderFooterTitles.swift b/DataSource/TableView/TableViewDataSourceWithHeaderFooterTitles.swift
index 99c446e..aac2303 100644
--- a/DataSource/TableView/TableViewDataSourceWithHeaderFooterTitles.swift
+++ b/DataSource/TableView/TableViewDataSourceWithHeaderFooterTitles.swift
@@ -6,6 +6,7 @@
// Copyright (c) 2015 Fueled. All rights reserved.
//
+#if canImport(UIKit)
import UIKit
/// A `TableViewDataSource` subclass that additionally provides
@@ -27,3 +28,4 @@ open class TableViewDataSourceWithHeaderFooterTitles: TableViewDataSource {
return item as? String
}
}
+#endif
diff --git a/DataSource/TableView/TableViewDataSourceWithHeaderFooterViews.swift b/DataSource/TableView/TableViewDataSourceWithHeaderFooterViews.swift
index 5002f5e..11f0ecb 100644
--- a/DataSource/TableView/TableViewDataSourceWithHeaderFooterViews.swift
+++ b/DataSource/TableView/TableViewDataSourceWithHeaderFooterViews.swift
@@ -6,6 +6,7 @@
// Copyright (c) 2015 Fueled. All rights reserved.
//
+#if canImport(UIKit)
import UIKit
/// A `TableViewDataSource` subclass that additionally provides
@@ -51,3 +52,4 @@ open class TableViewDataSourceWithHeaderFooterViews: TableViewDataSource, UITabl
return view
}
}
+#endif
diff --git a/DataSource/TableView/TableViewHeaderFooterView.swift b/DataSource/TableView/TableViewHeaderFooterView.swift
index acfd053..f9aa397 100644
--- a/DataSource/TableView/TableViewHeaderFooterView.swift
+++ b/DataSource/TableView/TableViewHeaderFooterView.swift
@@ -7,6 +7,7 @@
//
import Combine
+#if canImport(UIKit)
import UIKit
/// `UITableViewHeaderFooterView` subclass that implements `DataSourceItemReceiver` protocol
@@ -23,3 +24,4 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, DataSourceIte
self.viewModel.value = item
}
}
+#endif
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..2debb93
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,29 @@
+// swift-tools-version:5.5
+// The swift-tools-version declares the minimum version of Swift required to build this package.
+
+import PackageDescription
+
+let package = Package(
+ name: "DataSource",
+ platforms: [
+ .macOS(.v10_15), .iOS(.v13), .tvOS(.v13)
+ ],
+ products: [
+ .library(
+ name: "DataSource",
+ targets: ["DataSource"]
+ )
+ ],
+ targets: [
+ .target(
+ name: "DataSource",
+ path: "DataSource",
+ exclude: ["Info.plist"],
+ linkerSettings: [
+ .linkedFramework("Foundation"),
+ .linkedFramework("UIKit", BuildSettingCondition.when(platforms: [.iOS, .tvOS])),
+ .linkedFramework("AppKit", BuildSettingCondition.when(platforms: [.macOS]))
+ ]
+ )
+ ]
+)