Skip to content

Commit 92af5ec

Browse files
committed
Added tvOS Support.
1 parent 2c245b1 commit 92af5ec

26 files changed

+59
-52
lines changed

Example Apps/SPDiffable.xcodeproj/project.pbxproj

+6-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 52;
6+
objectVersion = 46;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -13,7 +13,6 @@
1313
F47A41FC24EB22A70054DBB2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F47A41EC24EB22A70054DBB2 /* Assets.xcassets */; };
1414
F47A41FD24EB22A70054DBB2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F47A41ED24EB22A70054DBB2 /* LaunchScreen.storyboard */; };
1515
F47A41FF24EB22A70054DBB2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47A41EF24EB22A70054DBB2 /* AppDelegate.swift */; };
16-
F4FA2E772658E5F200CBDD22 /* SPDiffable in Frameworks */ = {isa = PBXBuildFile; productRef = F4FA2E762658E5F200CBDD22 /* SPDiffable */; };
1716
/* End PBXBuildFile section */
1817

1918
/* Begin PBXCopyFilesBuildPhase section */
@@ -39,15 +38,14 @@
3938
F47A41EE24EB22A70054DBB2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
4039
F47A41EF24EB22A70054DBB2 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4140
F4977BC6252E079A00B20771 /* Entitlements.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Entitlements.entitlements; sourceTree = "<group>"; };
42-
F4FA2E742658E5C300CBDD22 /* SPDiffable */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SPDiffable; path = ..; sourceTree = "<group>"; };
41+
F4DE1B2A27B67B7E00A608F1 /* SPDiffable */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = SPDiffable; path = ..; sourceTree = "<group>"; };
4342
/* End PBXFileReference section */
4443

4544
/* Begin PBXFrameworksBuildPhase section */
4645
F47A41CB24EB222C0054DBB2 /* Frameworks */ = {
4746
isa = PBXFrameworksBuildPhase;
4847
buildActionMask = 2147483647;
4948
files = (
50-
F4FA2E772658E5F200CBDD22 /* SPDiffable in Frameworks */,
5149
);
5250
runOnlyForDeploymentPostprocessing = 0;
5351
};
@@ -103,7 +101,7 @@
103101
OBJ_5 = {
104102
isa = PBXGroup;
105103
children = (
106-
F4FA2E742658E5C300CBDD22 /* SPDiffable */,
104+
F4DE1B2A27B67B7E00A608F1 /* SPDiffable */,
107105
F47A41CF24EB222C0054DBB2 /* iOS Example */,
108106
OBJ_42 /* Products */,
109107
F4FA2E752658E5F200CBDD22 /* Frameworks */,
@@ -128,7 +126,6 @@
128126
);
129127
name = "Example iOS";
130128
packageProductDependencies = (
131-
F4FA2E762658E5F200CBDD22 /* SPDiffable */,
132129
);
133130
productName = Example;
134131
productReference = F47A41CE24EB222C0054DBB2 /* Example iOS.app */;
@@ -261,10 +258,7 @@
261258
GCC_WARN_UNUSED_VARIABLE = YES;
262259
INFOPLIST_FILE = "iOS Example/Info.plist";
263260
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
264-
LD_RUNPATH_SEARCH_PATHS = (
265-
"$(inherited)",
266-
"@executable_path/Frameworks",
267-
);
261+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
268262
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
269263
MTL_FAST_MATH = YES;
270264
PRODUCT_BUNDLE_IDENTIFIER = by.ivanvorobei.opensource.spdiffable;
@@ -327,10 +321,7 @@
327321
GCC_WARN_UNUSED_VARIABLE = YES;
328322
INFOPLIST_FILE = "iOS Example/Info.plist";
329323
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
330-
LD_RUNPATH_SEARCH_PATHS = (
331-
"$(inherited)",
332-
"@executable_path/Frameworks",
333-
);
324+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
334325
MTL_ENABLE_DEBUG_INFO = NO;
335326
MTL_FAST_MATH = YES;
336327
PRODUCT_BUNDLE_IDENTIFIER = by.ivanvorobei.opensource.spdiffable;
@@ -442,8 +433,7 @@
442433
SDKROOT = macosx;
443434
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
444435
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) SWIFT_PACKAGE";
445-
SWIFT_COMPILATION_MODE = wholemodule;
446-
SWIFT_OPTIMIZATION_LEVEL = "-O";
436+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
447437
USE_HEADERMAP = NO;
448438
};
449439
name = Release;
@@ -470,13 +460,6 @@
470460
defaultConfigurationName = Release;
471461
};
472462
/* End XCConfigurationList section */
473-
474-
/* Begin XCSwiftPackageProductDependency section */
475-
F4FA2E762658E5F200CBDD22 /* SPDiffable */ = {
476-
isa = XCSwiftPackageProductDependency;
477-
productName = SPDiffable;
478-
};
479-
/* End XCSwiftPackageProductDependency section */
480463
};
481464
rootObject = OBJ_1 /* Project object */;
482465
}

Example Apps/SPDiffable.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6-
<false/>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<true/>
77
</dict>
8-
</plist>
8+
</plist>

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55
let package = Package(
66
name: "SPDiffable",
77
platforms: [
8-
.iOS(.v12)
8+
.iOS(.v12), .tvOS(.v12)
99
],
1010
products: [
1111
.library(

SPDiffable.podspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPDiffable'
4-
s.version = '4.0.0'
4+
s.version = '4.0.4'
55
s.summary = 'Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.'
66
s.homepage = 'https://github.com/ivanvorobei/SPDiffable'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version }
@@ -10,6 +10,7 @@ Pod::Spec.new do |s|
1010

1111
s.swift_version = '5.1'
1212
s.ios.deployment_target = '12.0'
13+
s.tvos.deployment_target = '12.0'
1314

1415
s.source_files = 'Sources/SPDiffable/**/*.swift'
1516

Sources/SPDiffable/Collection/DataSource/AppleCollectionDiffableDataSource.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
class AppleCollectionDiffableDataSource: UICollectionViewDiffableDataSource<SPDiffableSection, SPDiffableItem> {
2626

2727
// MARK: - Init
@@ -37,8 +37,9 @@ class AppleCollectionDiffableDataSource: UICollectionViewDiffableDataSource<SPDi
3737

3838
// MARK: - Wrappers
3939

40+
@available(tvOS 13.0, *)
4041
typealias Snapshot = NSDiffableDataSourceSnapshot<SPDiffableSection, SPDiffableItem>
4142

42-
@available(iOS 14.0, *)
43+
@available(iOS 14.0, tvOS 14, *)
4344
typealias SectionSnapshot = NSDiffableDataSourceSectionSnapshot<SPDiffableItem>
4445
}

Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+CellProvider.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
extension SPDiffableCollectionDataSource {
2626

2727
open class CellProvider {
@@ -36,6 +36,7 @@ extension SPDiffableCollectionDataSource {
3636

3737
// MARK: - Ready Use
3838

39+
#if os(iOS)
3940
@available(iOS 14, *)
4041
public static var sideBar: [SPDiffableCollectionDataSource.CellProvider] {
4142
[sideBarItem, sideBarButton, sideBarHeader]
@@ -82,5 +83,6 @@ extension SPDiffableCollectionDataSource {
8283
return collectionView.dequeueConfiguredReusableCell(using: cellRegistration, for: indexPath, item: item)
8384
}
8485
}
86+
#endif
8587
}
8688
}

Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+HeaderFooterProvider.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
extension SPDiffableCollectionDataSource {
2626

2727
open class HeaderFooterProvider {

Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource+UICollectionViewDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
extension SPDiffableCollectionDataSource: UICollectionViewDelegate {
2626

2727
open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterface {
2626

2727
open weak var diffableDelegate: SPDiffableCollectionDelegate?
@@ -106,7 +106,7 @@ open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterfa
106106

107107
// Update items in Sections
108108

109-
if #available(iOS 14.0, *) {
109+
if #available(iOS 14.0, tvOS 14, *) {
110110
for section in sections {
111111
var sectionSnapshot = AppleCollectionDiffableDataSource.SectionSnapshot()
112112

@@ -155,7 +155,7 @@ open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterfa
155155
// Update snapshot
156156

157157
var snapshot = convertToSnapshot(sections)
158-
if #available(iOS 15.0, *) {
158+
if #available(iOS 15.0, tvOS 15, *) {
159159
snapshot.reconfigureItems(items)
160160
} else {
161161
snapshot.reloadItems(items)
@@ -165,7 +165,7 @@ open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterfa
165165

166166
public func reconfigure(_ items: [SPDiffableItem]) {
167167
guard var snapshot = appleDiffableDataSource?.snapshot() else { return }
168-
if #available(iOS 15.0, *) {
168+
if #available(iOS 15.0, tvOS 15, *) {
169169
snapshot.reconfigureItems(items)
170170
} else {
171171
snapshot.reloadItems(items)

Sources/SPDiffable/Collection/Models/SPDiffableSideBarButton.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import UIKit
2626

2727
Colorful title usually.
2828
*/
29-
@available(iOS 14, *)
29+
@available(iOS 14, tvOS 14, *)
3030
open class SPDiffableSideBarButton: SPDiffableActionableItem {
3131

3232
open var title: String

Sources/SPDiffable/Collection/Models/SPDiffableSideBarHeader.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import UIKit
2424
/**
2525
SPDiffable: Header model for side bar item.
2626
*/
27-
@available(iOS 14, *)
27+
@available(iOS 14, tvOS 14, *)
2828
open class SPDiffableSideBarHeader: SPDiffableItem {
2929

3030
open var text: String

Sources/SPDiffable/Collection/Models/SPDiffableSideBarItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import UIKit
2626

2727
For header use `SPDiffableSideBarHeader` class.
2828
*/
29-
@available(iOS 14, *)
29+
@available(iOS 14, tvOS 14, *)
3030
open class SPDiffableSideBarItem: SPDiffableActionableItem {
3131

3232
open var title: String

Sources/SPDiffable/Collection/SPDiffableCollectionController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
open class SPDiffableCollectionController: UICollectionViewController {
2626

2727
open var diffableDataSource: SPDiffableCollectionDataSource?

Sources/SPDiffable/Collection/SPDiffableCollectionView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
open class SPDiffableCollectionView: UICollectionView, UICollectionViewDelegate {
2626

2727
open var diffableDataSource: SPDiffableCollectionDataSource?

Sources/SPDiffable/Collection/SPDiffableSideBarButtonCollectionViewListCell.swift

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(UIKit) && os(iOS)
2223
import UIKit
2324

2425
@available(iOS 14, *)
@@ -49,3 +50,4 @@ class SPDiffableSideBarButtonCollectionViewListCell: UICollectionViewListCell {
4950
didSet { if isSelected { isSelected = false } }
5051
}
5152
}
53+
#endif

Sources/SPDiffable/Collection/SPDiffableSideBarController.swift

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(UIKit) && os(iOS)
2223
import UIKit
2324

2425
@available(iOS 14, *)
@@ -53,3 +54,4 @@ open class SPDiffableSideBarController: SPDiffableCollectionController {
5354
}
5455
}
5556
}
57+
#endif

Sources/SPDiffable/Table/Cells/SPDiffableTableViewCell.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ open class SPDiffableTableViewCell: UITableViewCell {
4141

4242
open override func sizeThatFits(_ size: CGSize) -> CGSize {
4343
let superSize = super.sizeThatFits(size)
44-
return .init(width: superSize.width, height: superSize.height + 4)
44+
return .init(width: superSize.width, height: superSize.height)
4545
}
4646
}

Sources/SPDiffable/Table/Cells/Views/SPDiffableSlider.swift

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(UIKit) && os(iOS)
2223
import UIKit
2324

2425
open class SPDiffableSlider: UISlider {
@@ -40,3 +41,5 @@ open class SPDiffableSlider: UISlider {
4041
action(Double(value))
4142
}
4243
}
44+
#endif
45+

Sources/SPDiffable/Table/Cells/Views/SPDiffableStepper.swift

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(UIKit) && os(iOS)
2223
import UIKit
2324

2425
open class SPDiffableStepper: UIStepper {
@@ -40,3 +41,4 @@ open class SPDiffableStepper: UIStepper {
4041
action(value)
4142
}
4243
}
44+
#endif

Sources/SPDiffable/Table/Cells/Views/SPDiffableSwitch.swift

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
// SOFTWARE.
2121

22+
#if canImport(UIKit) && os(iOS)
2223
import UIKit
2324

2425
open class SPDiffableSwitch: UISwitch {
@@ -39,3 +40,4 @@ open class SPDiffableSwitch: UISwitch {
3940
action(isOn)
4041
}
4142
}
43+
#endif

Sources/SPDiffable/Table/DataSource/AppleTableDiffableDataSource.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import UIKit
2323

24-
@available(iOS 13.0, *)
24+
@available(iOS 13.0, tvOS 13, *)
2525
class AppleTableDiffableDataSource: UITableViewDiffableDataSource<SPDiffableSection, SPDiffableItem> {
2626

2727
weak var mediator: SPDiffableTableMediator?

0 commit comments

Comments
 (0)