Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
xcuserdata
*.xccheckout
Carthage/Build
.build
.swiftpm
2 changes: 2 additions & 0 deletions DataSource/CollectionView/CollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Combine
#if canImport(UIKit)
import UIKit

/// `UICollectionViewCell` subclass that implements `DataSourceItemReceiver` protocol
Expand All @@ -23,3 +24,4 @@ open class CollectionViewCell: UICollectionViewCell, DataSourceItemReceiver {
self.cellModel.value = item
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/CollectionView/CollectionViewChangeTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
#if canImport(UIKit)
import UIKit

extension UICollectionView: DataChangeTarget {
Expand Down Expand Up @@ -50,3 +51,4 @@ extension UICollectionView: DataChangeTarget {
self.reloadSections(IndexSet(dsIntegers: sections))
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/CollectionView/CollectionViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Combine
import Foundation
#if canImport(UIKit)
import UIKit

/// An object that implements `UICollectionViewDataSource` protocol
Expand Down Expand Up @@ -104,3 +105,4 @@ open class CollectionViewDataSource: NSObject, UICollectionViewDataSource {
return cell
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/CollectionView/CollectionViewReusableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Combine
#if canImport(UIKit)
import UIKit

/// `UICollectionReusableView` subclass that implements `DataSourceItemReceiver` protocol
Expand All @@ -23,3 +24,4 @@ open class CollectionViewReusableView: UICollectionReusableView, DataSourceItemR
self.viewModel.value = item
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/DataSourceCellDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2019 Fueled. All rights reserved.
//

#if canImport(UIKit)
import UIKit

public class CellDescriptor: NSObject {
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion DataSource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Fueled. All rights reserved.</string>
<string>Copyright © 2022 Fueled. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 2 additions & 0 deletions DataSource/TableView/TableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Combine
#if canImport(UIKit)
import UIKit

/// `UITableViewCell` subclass that implements `DataSourceItemReceiver` protocol
Expand All @@ -23,3 +24,4 @@ open class TableViewCell: UITableViewCell, DataSourceItemReceiver {
self.cellModel.value = item
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/TableView/TableViewChangeTarget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
#if canImport(UIKit)
import UIKit

extension UITableView: DataChangeTarget {
Expand Down Expand Up @@ -53,3 +54,4 @@ extension UITableView: DataChangeTarget {
self.reloadSections(IndexSet(dsIntegers: sections), with: .fade)
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/TableView/TableViewDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Combine
import Foundation
#if canImport(UIKit)
import UIKit

/// An object that implements `UITableViewDataSource` protocol
Expand Down Expand Up @@ -91,3 +92,4 @@ open class TableViewDataSource: NSObject, UITableViewDataSource {
return cell
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2015 Fueled. All rights reserved.
//

#if canImport(UIKit)
import UIKit

/// A `TableViewDataSource` subclass that additionally provides
Expand All @@ -27,3 +28,4 @@ open class TableViewDataSourceWithHeaderFooterTitles: TableViewDataSource {
return item as? String
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2015 Fueled. All rights reserved.
//

#if canImport(UIKit)
import UIKit

/// A `TableViewDataSource` subclass that additionally provides
Expand Down Expand Up @@ -51,3 +52,4 @@ open class TableViewDataSourceWithHeaderFooterViews: TableViewDataSource, UITabl
return view
}
}
#endif
2 changes: 2 additions & 0 deletions DataSource/TableView/TableViewHeaderFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Combine
#if canImport(UIKit)
import UIKit

/// `UITableViewHeaderFooterView` subclass that implements `DataSourceItemReceiver` protocol
Expand All @@ -23,3 +24,4 @@ open class TableViewHeaderFooterView: UITableViewHeaderFooterView, DataSourceIte
self.viewModel.value = item
}
}
#endif
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are excluding the Info.plist file to avoid conflicts when adding this library to a project?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to exclude it otherwise the build system tries to compile the plist file, and fails.

linkerSettings: [
.linkedFramework("Foundation"),
.linkedFramework("UIKit", BuildSettingCondition.when(platforms: [.iOS, .tvOS])),
.linkedFramework("AppKit", BuildSettingCondition.when(platforms: [.macOS]))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can omit the BuildSettingCondition from here 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't even think the linkerSettings section is needed though. I'll try removing the section and see how that goes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think It's similar to using UIKit that already contains Foundation?
By importing the DataSource we can then remove the UIKit or Foundation imports from our code?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hadiidbouk nope, the import are not transitive, we still need to import Foundation & import UIKit when using the relevant APIs. When using an ObjC bridging header however, Foundation is usually implicitly imported

]
)
]
)