From 25cbfbdfd8bd6d30f9ca0a4aec7cccce2ebef635 Mon Sep 17 00:00:00 2001 From: Mohamed Afifi Date: Thu, 19 Mar 2020 18:39:27 -0400 Subject: [PATCH 1/6] Xcode 11 & Swift 5 upgrade --- Example/Example.xcodeproj/project.pbxproj | 12 +++++---- .../xcshareddata/xcschemes/Example.xcscheme | 10 +++---- GenericDataSource.xcodeproj/project.pbxproj | 26 +++++++++++-------- .../xcschemes/GenericDataSource.xcscheme | 26 +++++++++---------- Sources/AnyBasicDataSourceRepresentable.swift | 4 +-- Sources/AnyDataSourceSelectionHandler.swift | 2 +- Sources/BasicBlockDataSource.swift | 2 +- Sources/BasicDataSource.swift | 2 +- Sources/BasicDataSourceRepresentable.swift | 2 +- Sources/BlockSelectionHandler.swift | 2 +- Sources/SegmentedDataSource.swift | 4 +-- Sources/UnselectableSelectionHandler.swift | 2 +- Sources/_DataSourcesCollection.swift | 8 +++--- 13 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 85e4ccf..5c3583d 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -300,18 +300,18 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1130; ORGANIZATIONNAME = "Mohamed Afifi"; TargetAttributes = { 547447501CA93C1D00F3597E = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 1000; + LastSwiftMigration = 1130; }; }; }; buildConfigurationList = 5474474C1CA93C1C00F3597E /* Build configuration list for PBXProject "Example" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -432,6 +432,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -488,6 +489,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; @@ -543,7 +545,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -556,7 +558,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.Example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index e5b686b..ba4181b 100644 --- a/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/Example/Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + + + + @@ -40,17 +49,6 @@ - - - - - - : BasicDataSourceRepr var items: [Item] { get { fatalError() } - set { fatalError() } + set { fatalError() } // swiftlint:disable:this unused_setter_value } var dataSource: AbstractDataSource { fatalError() } var onItemsUpdated: (([Item]) -> Void)? { get { fatalError() } - set { fatalError() } + set { fatalError() } // swiftlint:disable:this unused_setter_value } } diff --git a/Sources/AnyDataSourceSelectionHandler.swift b/Sources/AnyDataSourceSelectionHandler.swift index e17bb8b..15d90fc 100644 --- a/Sources/AnyDataSourceSelectionHandler.swift +++ b/Sources/AnyDataSourceSelectionHandler.swift @@ -11,7 +11,7 @@ import Foundation /** * Type-erasure for `DataSourceSelectionHandler`. */ -public struct AnyDataSourceSelectionHandler : DataSourceSelectionHandler { +public struct AnyDataSourceSelectionHandler: DataSourceSelectionHandler { private let itemsChanged: (BasicDataSource) -> Void private let configureCell: (BasicDataSource, GeneralCollectionView, CellType, ItemType, IndexPath) -> Void diff --git a/Sources/BasicBlockDataSource.swift b/Sources/BasicBlockDataSource.swift index 0f346e7..aa95cea 100644 --- a/Sources/BasicBlockDataSource.swift +++ b/Sources/BasicBlockDataSource.swift @@ -11,7 +11,7 @@ import Foundation /** A basic data source class that configures the cells with a closure. */ -open class BasicBlockDataSource : BasicDataSource { +open class BasicBlockDataSource: BasicDataSource { /// The configure closure type. public typealias ConfigureBlock = (ItemType, CellType, IndexPath) -> Void diff --git a/Sources/BasicDataSource.swift b/Sources/BasicDataSource.swift index a824556..c05024f 100644 --- a/Sources/BasicDataSource.swift +++ b/Sources/BasicDataSource.swift @@ -18,7 +18,7 @@ import UIKit For sizing cells, you can use `itemSize` for `UICollectionView` and `itemHeight` for `UITableView`. Or if you want to specify a custom size, you can override `ds_collectionView(_:sizeForItemAt:)`, **but needs** to set `useDelegateForItemSize` to `true` otherwise the overriden method will not be called. */ -open class BasicDataSource : AbstractDataSource, BasicDataSourceRepresentable { +open class BasicDataSource: AbstractDataSource, BasicDataSourceRepresentable { /// Returns a string that describes the contents of the receiver. open override var description: String { diff --git a/Sources/BasicDataSourceRepresentable.swift b/Sources/BasicDataSourceRepresentable.swift index 274782f..f33cee0 100644 --- a/Sources/BasicDataSourceRepresentable.swift +++ b/Sources/BasicDataSourceRepresentable.swift @@ -67,6 +67,6 @@ extension BasicDataSourceRepresentable where Item: Equatable { - returns: The index path for a certain item, or `nil` if there is no such item. */ public func indexPath(for item: Item) -> IndexPath? { - return items.index(of: item).flatMap { IndexPath(item: $0, section: 0) } + return items.firstIndex(of: item).flatMap { IndexPath(item: $0, section: 0) } } } diff --git a/Sources/BlockSelectionHandler.swift b/Sources/BlockSelectionHandler.swift index fe4a1c0..5109b6b 100644 --- a/Sources/BlockSelectionHandler.swift +++ b/Sources/BlockSelectionHandler.swift @@ -13,7 +13,7 @@ import Foundation It's mainly used with `BasicDataSource`. It also can work with `BasicDataSource` nested inside multiple `CompositeDataSource`. You can have one handler for each data source. */ -open class BlockSelectionHandler : DataSourceSelectionHandler { +open class BlockSelectionHandler: DataSourceSelectionHandler { /// Whether to always allow highlighting or not. This variable used when `shouldHighlightBlock` is nil. open var defaultShouldHighlight: Bool = true diff --git a/Sources/SegmentedDataSource.swift b/Sources/SegmentedDataSource.swift index f77d088..092f1c3 100644 --- a/Sources/SegmentedDataSource.swift +++ b/Sources/SegmentedDataSource.swift @@ -41,7 +41,7 @@ open class SegmentedDataSource: AbstractDataSource, CollectionDataSource { selectedDataSource = dataSources[newValue] } get { - return dataSources.index { $0 === selectedDataSource } ?? NSNotFound + return dataSources.firstIndex { $0 === selectedDataSource } ?? NSNotFound } } @@ -140,7 +140,7 @@ open class SegmentedDataSource: AbstractDataSource, CollectionDataSource { - returns: The index of the data source. */ open func index(of dataSource: DataSource) -> Int? { - return dataSources.index { $0 === dataSource } + return dataSources.firstIndex { $0 === dataSource } } // MARK: - Responds diff --git a/Sources/UnselectableSelectionHandler.swift b/Sources/UnselectableSelectionHandler.swift index 75b59da..9af92ea 100644 --- a/Sources/UnselectableSelectionHandler.swift +++ b/Sources/UnselectableSelectionHandler.swift @@ -9,7 +9,7 @@ import Foundation /// A selection handler that always disallow selection and highlighting. -public struct UnselectableSelectionHandler : DataSourceSelectionHandler { +public struct UnselectableSelectionHandler: DataSourceSelectionHandler { /// Creates new instance. public init() { diff --git a/Sources/_DataSourcesCollection.swift b/Sources/_DataSourcesCollection.swift index b98e33b..2e93be8 100644 --- a/Sources/_DataSourcesCollection.swift +++ b/Sources/_DataSourcesCollection.swift @@ -14,8 +14,8 @@ private class _DataSourceWrapper: Hashable { self.dataSource = dataSource } - var hashValue: Int { - return Unmanaged.passUnretained(dataSource).toOpaque().hashValue + func hash(into hasher: inout Hasher) { + hasher.combine(Unmanaged.passUnretained(dataSource).toOpaque()) } } @@ -119,7 +119,7 @@ extension _DataSourcesCollection { let wrapper = _DataSourceWrapper(dataSource: dataSource) let exsitingMapping: _DataSourcesCollectionMapping = cast(mappings.dataSourceToMappings[wrapper], message: "Tried to remove a data source that doesn't exist: \(dataSource)") - let index: Int = cast(mappings.array.index(of: exsitingMapping), message: "Tried to remove a data source that doesn't exist: \(dataSource)") + let index: Int = cast(mappings.array.firstIndex(of: exsitingMapping), message: "Tried to remove a data source that doesn't exist: \(dataSource)") mappings.dataSourceToMappings[wrapper] = nil mappings.array.remove(at: index) @@ -159,7 +159,7 @@ extension _DataSourcesCollection { guard let mapping = mapping(of: dataSource) else { return nil } - return mappings.array.index(of: mapping) + return mappings.array.firstIndex(of: mapping) } func mapping(of dataSource: DataSource) -> _DataSourcesCollectionMapping? { From 95c94abd0484ea77edec43aada05927704f7afbf Mon Sep 17 00:00:00 2001 From: Mohamed Afifi Date: Thu, 19 Mar 2020 18:41:14 -0400 Subject: [PATCH 2/6] Version Bump to 3.1.0 --- GenericDataSource.xcodeproj/project.pbxproj | 2 ++ GenericDataSources.podspec | 2 +- Sources/Info.plist | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/GenericDataSource.xcodeproj/project.pbxproj b/GenericDataSource.xcodeproj/project.pbxproj index cc6ad62..a88c096 100644 --- a/GenericDataSource.xcodeproj/project.pbxproj +++ b/GenericDataSource.xcodeproj/project.pbxproj @@ -979,6 +979,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 3.1.0; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.GenericDataSource; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -999,6 +1000,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 3.1.0; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.GenericDataSource; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/GenericDataSources.podspec b/GenericDataSources.podspec index 28077c6..92815c7 100644 --- a/GenericDataSources.podspec +++ b/GenericDataSources.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GenericDataSources' - s.version = '3.0.2' + s.version = '3.1.0' s.license = 'MIT' s.summary = 'A generic small composable components for data source implementation for UITableView and UICollectionView.' s.homepage = 'https://github.com/GenericDataSource/GenericDataSource' diff --git a/Sources/Info.plist b/Sources/Info.plist index 49ca846..ca23c84 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.0.2 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion From 2cba8a4dbab242ffd037d48182703759be0d7377 Mon Sep 17 00:00:00 2001 From: Mohamed Afifi Date: Thu, 19 Mar 2020 18:57:22 -0400 Subject: [PATCH 3/6] SwiftPM Supoort --- .gitignore | 1 + .../contents.xcworkspacedata | 3 +++ Package.swift | 18 +++++++++++++++++- .../BasicBlockSupplementaryViewCreator.swift | 2 +- Sources/BasicSupplementaryViewCreator.swift | 2 +- Sources/BatchUpdater.swift | 2 +- Sources/CollectionDataSource.swift | 2 ++ .../CompositeSupplementaryViewCreator.swift | 2 +- Sources/DataSource.swift | 2 +- Sources/DataSourceSelector.swift | 2 +- Sources/GeneralCollectionView.swift | 2 +- ...neralCollectionViewFocusUpdateContext.swift | 2 +- Sources/ReusableCell.swift | 2 +- Sources/ReusableSupplementaryView.swift | 2 +- Sources/ReusableView.swift | 2 ++ Sources/SegmentedDataSource.swift | 2 +- Sources/SupplementaryViewCreator.swift | 2 +- Sources/UICollectionView+CollectionView.swift | 2 +- Sources/UIKitExtensions.swift | 2 +- Sources/UITableView+CollectionView.swift | 2 +- Sources/_Utilities.swift | 2 +- 21 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 3a9dd72..c7ac36a 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Xcode # build/ +.build/ .DS_Store *.pbxuser !default.pbxuser diff --git a/GenericDataSource.xcworkspace/contents.xcworkspacedata b/GenericDataSource.xcworkspace/contents.xcworkspacedata index 2060826..bf10e0b 100644 --- a/GenericDataSource.xcworkspace/contents.xcworkspacedata +++ b/GenericDataSource.xcworkspace/contents.xcworkspacedata @@ -4,6 +4,9 @@ + + diff --git a/Package.swift b/Package.swift index 4794a97..58e86a3 100644 --- a/Package.swift +++ b/Package.swift @@ -1,5 +1,21 @@ +// swift-tools-version:5.1 + import PackageDescription let package = Package( - name: "GenericDataSource" + name: "GenericDataSources", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "GenericDataSources", + targets: ["GenericDataSources"]), + ], + dependencies: [ + ], + targets: [ + .target( + name: "GenericDataSources", + dependencies: [], + path: "Sources") + ] ) diff --git a/Sources/BasicBlockSupplementaryViewCreator.swift b/Sources/BasicBlockSupplementaryViewCreator.swift index a007392..f85d3fe 100644 --- a/Sources/BasicBlockSupplementaryViewCreator.swift +++ b/Sources/BasicBlockSupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the basic supplementary view creator subclass that does the configuration using a closure. /// For more information see `BasicSupplementaryViewCreator` diff --git a/Sources/BasicSupplementaryViewCreator.swift b/Sources/BasicSupplementaryViewCreator.swift index b0791bd..cacaeb5 100644 --- a/Sources/BasicSupplementaryViewCreator.swift +++ b/Sources/BasicSupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the basic supplementary view creator. /// It manages supplementary views and items to bind to those views. diff --git a/Sources/BatchUpdater.swift b/Sources/BatchUpdater.swift index bbbf2e6..2417dd5 100644 --- a/Sources/BatchUpdater.swift +++ b/Sources/BatchUpdater.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit protocol BatchUpdater: class { diff --git a/Sources/CollectionDataSource.swift b/Sources/CollectionDataSource.swift index d6354e9..0cf4c0f 100644 --- a/Sources/CollectionDataSource.swift +++ b/Sources/CollectionDataSource.swift @@ -6,6 +6,8 @@ // Copyright © 2017 mohamede1945. All rights reserved. // +import Foundation + /// Represents the collection data source used as public protocol CollectionDataSource: DataSource { diff --git a/Sources/CompositeSupplementaryViewCreator.swift b/Sources/CompositeSupplementaryViewCreator.swift index e7a96a8..66718ea 100644 --- a/Sources/CompositeSupplementaryViewCreator.swift +++ b/Sources/CompositeSupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents a supplementary view creator that manages other creators depending on the kind. /// diff --git a/Sources/DataSource.swift b/Sources/DataSource.swift index 1191c3f..a0fddde 100644 --- a/Sources/DataSource.swift +++ b/Sources/DataSource.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// The DataSource protocol is a general data source and delegate protocol for both a UITableViewDataSource/UITableViewDelegate and UICollectionViewDataSource/UICollectionViewDelegate and adopted by an object that mediates the application’™s data model for a view object (e.g. `UITableView` or `UICollectionView`. @objc public protocol DataSource: class { diff --git a/Sources/DataSourceSelector.swift b/Sources/DataSourceSelector.swift index a7e9189..aee69c7 100644 --- a/Sources/DataSourceSelector.swift +++ b/Sources/DataSourceSelector.swift @@ -6,7 +6,7 @@ // Copyright © 2017 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the data source selectors that can be optional. /// Each case corresponds to a selector in the DataSource. diff --git a/Sources/GeneralCollectionView.swift b/Sources/GeneralCollectionView.swift index 08f2a84..5e64655 100644 --- a/Sources/GeneralCollectionView.swift +++ b/Sources/GeneralCollectionView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /** The GeneralCollectionView protocol unifies the interface of the `UICollectionView` and diff --git a/Sources/GeneralCollectionViewFocusUpdateContext.swift b/Sources/GeneralCollectionViewFocusUpdateContext.swift index 8e4614f..d877e64 100644 --- a/Sources/GeneralCollectionViewFocusUpdateContext.swift +++ b/Sources/GeneralCollectionViewFocusUpdateContext.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents a focus update context protocol to be something general for `UIFocusUpdateContext`. @available(iOS 9.0, *) diff --git a/Sources/ReusableCell.swift b/Sources/ReusableCell.swift index a0cc341..1ec177f 100644 --- a/Sources/ReusableCell.swift +++ b/Sources/ReusableCell.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /** Represents the reusable cell protocol for all resuable cells mainliy `UITableViewCell` and `UICollectionViewCell`. diff --git a/Sources/ReusableSupplementaryView.swift b/Sources/ReusableSupplementaryView.swift index 24c78a8..cb252d0 100644 --- a/Sources/ReusableSupplementaryView.swift +++ b/Sources/ReusableSupplementaryView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the protocol for reusable supplementary view. /// Subclasses can be used as return type for supplementary view of kind methods. diff --git a/Sources/ReusableView.swift b/Sources/ReusableView.swift index df6777f..47c9eca 100644 --- a/Sources/ReusableView.swift +++ b/Sources/ReusableView.swift @@ -6,6 +6,8 @@ // Copyright © 2017 mohamede1945. All rights reserved. // +import Foundation + /// The base protocol for any reusable view whether it is a cell or a supplementary view. /// It is used to give default reuse identifier and nib name. @objc public protocol ReusableView { diff --git a/Sources/SegmentedDataSource.swift b/Sources/SegmentedDataSource.swift index 092f1c3..5d78e2b 100644 --- a/Sources/SegmentedDataSource.swift +++ b/Sources/SegmentedDataSource.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// The composite data source class that is responsible for managing a set of children data sources. /// Delegating requests to the selected child data source to respond. diff --git a/Sources/SupplementaryViewCreator.swift b/Sources/SupplementaryViewCreator.swift index 639301b..c8e0ddf 100644 --- a/Sources/SupplementaryViewCreator.swift +++ b/Sources/SupplementaryViewCreator.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit /// Represents the protocol for types wanting to handle supplementary view creation and configurations. /// Usually using `BasicSupplementaryViewCreator` or `CompsiteSupplentaryViewCreator` is enough. diff --git a/Sources/UICollectionView+CollectionView.swift b/Sources/UICollectionView+CollectionView.swift index a3f8b30..e75dbdc 100644 --- a/Sources/UICollectionView+CollectionView.swift +++ b/Sources/UICollectionView+CollectionView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension UICollectionView: GeneralCollectionView { diff --git a/Sources/UIKitExtensions.swift b/Sources/UIKitExtensions.swift index 46162c1..5b5a9d5 100644 --- a/Sources/UIKitExtensions.swift +++ b/Sources/UIKitExtensions.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension UITableView.ScrollPosition { init(scrollPosition: UICollectionView.ScrollPosition) { diff --git a/Sources/UITableView+CollectionView.swift b/Sources/UITableView+CollectionView.swift index 8cb3d67..5c758a6 100644 --- a/Sources/UITableView+CollectionView.swift +++ b/Sources/UITableView+CollectionView.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension UITableView: GeneralCollectionView { diff --git a/Sources/_Utilities.swift b/Sources/_Utilities.swift index ecc58b7..7b9fc36 100644 --- a/Sources/_Utilities.swift +++ b/Sources/_Utilities.swift @@ -6,7 +6,7 @@ // Copyright © 2016 mohamede1945. All rights reserved. // -import Foundation +import UIKit extension NSObjectProtocol { func cast(_ value: T, file: StaticString = #file, line: UInt = #line) -> U { From 5a4783387ea7eae44b4bb5035b47ba9469d8981e Mon Sep 17 00:00:00 2001 From: Mohamed Afifi Date: Thu, 19 Mar 2020 18:57:54 -0400 Subject: [PATCH 4/6] Version Bump to 3.1.1 --- GenericDataSource.xcodeproj/project.pbxproj | 4 ++-- GenericDataSources.podspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GenericDataSource.xcodeproj/project.pbxproj b/GenericDataSource.xcodeproj/project.pbxproj index a88c096..3566570 100644 --- a/GenericDataSource.xcodeproj/project.pbxproj +++ b/GenericDataSource.xcodeproj/project.pbxproj @@ -979,7 +979,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 3.1.0; + MARKETING_VERSION = 3.1.1; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.GenericDataSource; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -1000,7 +1000,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 3.1.0; + MARKETING_VERSION = 3.1.1; PRODUCT_BUNDLE_IDENTIFIER = mohamede1945.GenericDataSource; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/GenericDataSources.podspec b/GenericDataSources.podspec index 92815c7..95a50db 100644 --- a/GenericDataSources.podspec +++ b/GenericDataSources.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GenericDataSources' - s.version = '3.1.0' + s.version = '3.1.1' s.license = 'MIT' s.summary = 'A generic small composable components for data source implementation for UITableView and UICollectionView.' s.homepage = 'https://github.com/GenericDataSource/GenericDataSource' From b301a090c9fb1aa664e80f3960f0930f224ee217 Mon Sep 17 00:00:00 2001 From: Mohamed Afifi Date: Wed, 17 May 2023 22:29:22 -0400 Subject: [PATCH 5/6] Fix some warnings --- Sources/BasicDataSourceRepresentable.swift | 2 +- Sources/BasicSupplementaryViewCreator.swift | 1 + Sources/BatchUpdater.swift | 3 +-- Sources/DataSource.swift | 2 +- Sources/GeneralCollectionView.swift | 2 +- Sources/ReusableSupplementaryView.swift | 8 ++++---- Sources/SupplementaryViewCreator.swift | 1 + Sources/UIKitExtensions.swift | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Sources/BasicDataSourceRepresentable.swift b/Sources/BasicDataSourceRepresentable.swift index f33cee0..2095ccd 100644 --- a/Sources/BasicDataSourceRepresentable.swift +++ b/Sources/BasicDataSourceRepresentable.swift @@ -18,7 +18,7 @@ import Foundation /// let dsRepresentable2: AnyBasicDataSourceRepresentable = dataSource2.asBasicDataSourceRepresentable() /// let representables = [dsRepresentable1, dsRepresentable2] /// // representables is an array that doesn't care about the cell only the items. -public protocol BasicDataSourceRepresentable: class { +public protocol BasicDataSourceRepresentable: AnyObject { associatedtype Item /// Represents the underlying data source. diff --git a/Sources/BasicSupplementaryViewCreator.swift b/Sources/BasicSupplementaryViewCreator.swift index cacaeb5..08ad4d1 100644 --- a/Sources/BasicSupplementaryViewCreator.swift +++ b/Sources/BasicSupplementaryViewCreator.swift @@ -29,6 +29,7 @@ import UIKit /// - `collectionView(_, sizeForViewOfKind:, at:)` /// /// If you don't want to subclass this class, then you can use `BasicBlockSupplementaryViewCreator` instead. +@MainActor open class BasicSupplementaryViewCreator: NSObject, SupplementaryViewCreator { /// Represents the size of the supplementary views, if you want dynamic size, set this value to nil (which is default). diff --git a/Sources/BatchUpdater.swift b/Sources/BatchUpdater.swift index 2417dd5..06497eb 100644 --- a/Sources/BatchUpdater.swift +++ b/Sources/BatchUpdater.swift @@ -8,8 +8,7 @@ import UIKit -protocol BatchUpdater: class { - +protocol BatchUpdater: AnyObject { func actualPerformBatchUpdates(_ updates: (() -> Void)?, completion: ((Bool) -> Void)?) } diff --git a/Sources/DataSource.swift b/Sources/DataSource.swift index a0fddde..1dcad29 100644 --- a/Sources/DataSource.swift +++ b/Sources/DataSource.swift @@ -9,7 +9,7 @@ import UIKit /// The DataSource protocol is a general data source and delegate protocol for both a UITableViewDataSource/UITableViewDelegate and UICollectionViewDataSource/UICollectionViewDelegate and adopted by an object that mediates the application’™s data model for a view object (e.g. `UITableView` or `UICollectionView`. -@objc public protocol DataSource: class { +@objc public protocol DataSource: AnyObject { /// Asks the data source if it responds to a given selector. /// diff --git a/Sources/GeneralCollectionView.swift b/Sources/GeneralCollectionView.swift index 5e64655..9086cd0 100644 --- a/Sources/GeneralCollectionView.swift +++ b/Sources/GeneralCollectionView.swift @@ -14,7 +14,7 @@ import UIKit Besides, `CompositeDataSource` has different implementation that allows children data sources to manipulate the `UICollectionView` and/or `UITableView` as if the children data sources are in the same top level first section even if it's in a different section. */ -@objc public protocol GeneralCollectionView: class { +@objc public protocol GeneralCollectionView: AnyObject { /** Represents the underlying scroll view. Use this method if you want to get the diff --git a/Sources/ReusableSupplementaryView.swift b/Sources/ReusableSupplementaryView.swift index cb252d0..c338740 100644 --- a/Sources/ReusableSupplementaryView.swift +++ b/Sources/ReusableSupplementaryView.swift @@ -36,7 +36,7 @@ extension UICollectionView { /// - view: The supplementary view class. /// - bundle: An optional bundle parameter. Specify it if the cell is not in the main bundle. /// - kind: The kind of the supplementary view. - open func ds_register(supplementaryViewNib view: UICollectionReusableView.Type, in bundle: Bundle? = nil, forKind kind: String) { + public func ds_register(supplementaryViewNib view: UICollectionReusableView.Type, in bundle: Bundle? = nil, forKind kind: String) { register(UINib(nibName: view.ds_nibName, bundle: bundle), forSupplementaryViewOfKind: kind, withReuseIdentifier: view.ds_reuseId) } @@ -50,7 +50,7 @@ extension UICollectionView { /// - Parameters: /// - view: The supplementary view class. /// - kind: The kind of the supplementary view. - open func ds_register(supplementaryViewClass view: UICollectionReusableView.Type, forKind kind: String) { + public func ds_register(supplementaryViewClass view: UICollectionReusableView.Type, forKind kind: String) { register(view, forSupplementaryViewOfKind: kind, withReuseIdentifier: view.ds_reuseId) } } @@ -68,7 +68,7 @@ extension UITableView { /// - Parameters: /// - view: The supplementary view class. /// - bundle: An optional bundle parameter. Specify it if the cell is not in the main bundle. - open func ds_register(headerFooterNib view: UITableViewHeaderFooterView.Type, in bundle: Bundle? = nil) { + public func ds_register(headerFooterNib view: UITableViewHeaderFooterView.Type, in bundle: Bundle? = nil) { register(UINib(nibName: view.ds_nibName, bundle: bundle), forHeaderFooterViewReuseIdentifier: view.ds_reuseId) } @@ -81,7 +81,7 @@ extension UITableView { /// /// - Parameters: /// - view: The supplementary view class. - open func ds_register(headerFooterClass view: UITableViewHeaderFooterView.Type) { + public func ds_register(headerFooterClass view: UITableViewHeaderFooterView.Type) { register(view, forHeaderFooterViewReuseIdentifier: view.ds_reuseId) } } diff --git a/Sources/SupplementaryViewCreator.swift b/Sources/SupplementaryViewCreator.swift index c8e0ddf..b684a87 100644 --- a/Sources/SupplementaryViewCreator.swift +++ b/Sources/SupplementaryViewCreator.swift @@ -15,6 +15,7 @@ import UIKit /// You need to implement at least the following required functions: /// - `collectionView(_, viewOfKind:, at:)` /// - `collectionView(_, sizeForViewOfKind:, at:)` +@MainActor public protocol SupplementaryViewCreator { /// Gets the supplementary view for the passed kind at the specified index path. diff --git a/Sources/UIKitExtensions.swift b/Sources/UIKitExtensions.swift index 5b5a9d5..4809cfc 100644 --- a/Sources/UIKitExtensions.swift +++ b/Sources/UIKitExtensions.swift @@ -29,7 +29,7 @@ extension UITableView { - parameter dataSource: The data source to set for the table view. */ - open func ds_useDataSource(_ dataSource: AbstractDataSource) { + public func ds_useDataSource(_ dataSource: AbstractDataSource) { self.dataSource = dataSource self.delegate = dataSource dataSource.ds_reusableViewDelegate = self @@ -43,7 +43,7 @@ extension UICollectionView { - parameter dataSource: The data source to set for the table view. */ - open func ds_useDataSource(_ dataSource: AbstractDataSource) { + public func ds_useDataSource(_ dataSource: AbstractDataSource) { self.dataSource = dataSource self.delegate = dataSource dataSource.ds_reusableViewDelegate = self From 8b06dfd564afc80155ab0a30a2613dc8e04be1e9 Mon Sep 17 00:00:00 2001 From: takasurazeem Date: Sun, 15 Oct 2023 18:18:47 +0500 Subject: [PATCH 6/6] Xcode 15 compilation error. (#18) --- Sources/BasicDataSource.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/BasicDataSource.swift b/Sources/BasicDataSource.swift index c05024f..ad588e5 100644 --- a/Sources/BasicDataSource.swift +++ b/Sources/BasicDataSource.swift @@ -57,7 +57,7 @@ open class BasicDataSource: AbstractDataSource then those properties sets this property to `true`. */ @available(*, unavailable, message: "Now, we can detect if you implemented sizeForItemAt or not") - open var useDelegateForItemSize: Bool = false + open var useDelegateForItemSize: Bool { return false } /// Represents the underlying data source which is `self`. open var dataSource: AbstractDataSource { return self }