From dac79f27c38f95a3b7ca5aeef6b22b353a16d983 Mon Sep 17 00:00:00 2001 From: Florian Fittschen Date: Thu, 4 Mar 2021 15:14:54 +0100 Subject: [PATCH] Add Swift Package Manager support --- .gitignore | 1 + Package.swift | 29 +++++++++++++++++-- Sources/CalendarEnums.swift | 2 ++ Sources/CalendarStructs.swift | 1 + Sources/GlobalFunctionsAndExtensions.swift | 2 ++ Sources/JTAppleCalendarDelegateProtocol.swift | 2 ++ Sources/JTAppleCalendarLayout.swift | 2 ++ Sources/JTAppleCalendarLayoutProtocol.swift | 1 + Sources/JTAppleCalendarVariables.swift | 2 ++ Sources/JTAppleCalendarView.swift | 2 ++ Sources/JTAppleCell.swift | 2 ++ Sources/JTAppleCollectionReusableView.swift | 2 ++ Sources/JTCalendarProtocols.swift | 2 ++ Sources/UICollectionViewDelegates.swift | 2 ++ Sources/UIScrollViewDelegates.swift | 2 ++ Sources/UserInteractionFunctions.swift | 1 + Tests/JTAppleCalendar_iOSTests.swift | 2 +- 17 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0b5cf1bd..f5f545f6 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ Carthage #xcshareddata /.swiftlint.yml /JTAppleCalendar.xcworkspace/xcshareddata/JTAppleCalendar.xcscmblueprint +.swiftpm/ \ No newline at end of file diff --git a/Package.swift b/Package.swift index f193873a..90a8a041 100644 --- a/Package.swift +++ b/Package.swift @@ -1,6 +1,31 @@ -import PackageDescription +// swift-tools-version:5.3 +import PackageDescription let package = Package( - name: "JTAppleCalendar" + name: "JTAppleCalendar", + products: [ + .library( + name: "JTAppleCalendar", + targets: ["JTAppleCalendar"] + ), + ], + targets: [ + .target( + name: "JTAppleCalendar", + path: "Sources", + exclude: [ + "Info-iOS.plist", + "Info-tvOS.plist" + ] + ), + .testTarget( + name: "JTAppleCalendarTests", + dependencies: ["JTAppleCalendar"], + path: "Tests", + exclude: [ + "Info.plist" + ] + ), + ] ) diff --git a/Sources/CalendarEnums.swift b/Sources/CalendarEnums.swift index c70d9c34..0cc812a8 100644 --- a/Sources/CalendarEnums.swift +++ b/Sources/CalendarEnums.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + /// Describes a scroll destination public enum SegmentDestination { /// next the destination is the following segment diff --git a/Sources/CalendarStructs.swift b/Sources/CalendarStructs.swift index 29dd04e4..feef9621 100644 --- a/Sources/CalendarStructs.swift +++ b/Sources/CalendarStructs.swift @@ -22,6 +22,7 @@ // THE SOFTWARE. // +import UIKit /// Describes which month the cell belongs to /// - ThisMonth: Cell belongs to the current month diff --git a/Sources/GlobalFunctionsAndExtensions.swift b/Sources/GlobalFunctionsAndExtensions.swift index f242a396..35a6704e 100644 --- a/Sources/GlobalFunctionsAndExtensions.swift +++ b/Sources/GlobalFunctionsAndExtensions.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + extension Calendar { static let formatter: DateFormatter = { let dateFormatter = DateFormatter() diff --git a/Sources/JTAppleCalendarDelegateProtocol.swift b/Sources/JTAppleCalendarDelegateProtocol.swift index 8bed3998..95e3d422 100644 --- a/Sources/JTAppleCalendarDelegateProtocol.swift +++ b/Sources/JTAppleCalendarDelegateProtocol.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + protocol JTAppleCalendarDelegateProtocol: class { // Variables var allowsDateCellStretching: Bool {get set} diff --git a/Sources/JTAppleCalendarLayout.swift b/Sources/JTAppleCalendarLayout.swift index e50d0719..4a046de4 100644 --- a/Sources/JTAppleCalendarLayout.swift +++ b/Sources/JTAppleCalendarLayout.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + /// Methods in this class are meant to be overridden and will be called by its collection view to gather layout information. class JTAppleCalendarLayout: UICollectionViewLayout, JTAppleCalendarLayoutProtocol { diff --git a/Sources/JTAppleCalendarLayoutProtocol.swift b/Sources/JTAppleCalendarLayoutProtocol.swift index 0366ec76..17ba1aff 100644 --- a/Sources/JTAppleCalendarLayoutProtocol.swift +++ b/Sources/JTAppleCalendarLayoutProtocol.swift @@ -22,6 +22,7 @@ // THE SOFTWARE. // +import UIKit protocol JTAppleCalendarLayoutProtocol: class { var minimumInteritemSpacing: CGFloat {get set} diff --git a/Sources/JTAppleCalendarVariables.swift b/Sources/JTAppleCalendarVariables.swift index e9613314..d201b3f0 100644 --- a/Sources/JTAppleCalendarVariables.swift +++ b/Sources/JTAppleCalendarVariables.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + // Calculated Variables extension JTAppleCalendarView { /// Workaround for Xcode bug that prevents you from connecting the delegate in the storyboard. diff --git a/Sources/JTAppleCalendarView.swift b/Sources/JTAppleCalendarView.swift index cc7af5bc..5b163d96 100644 --- a/Sources/JTAppleCalendarView.swift +++ b/Sources/JTAppleCalendarView.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + let maxNumberOfDaysInWeek = 7 // Should not be changed let maxNumberOfRowsPerMonth = 6 // Should not be changed let developerErrorMessage = "There was an error in this code section. Please contact the developer on GitHub" diff --git a/Sources/JTAppleCell.swift b/Sources/JTAppleCell.swift index e5e065cc..8568a9df 100644 --- a/Sources/JTAppleCell.swift +++ b/Sources/JTAppleCell.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + /// The JTAppleCell class defines the attributes and /// behavior of the cells that appear in JTAppleCalendarView objects. open class JTAppleCell: UICollectionViewCell { diff --git a/Sources/JTAppleCollectionReusableView.swift b/Sources/JTAppleCollectionReusableView.swift index a2b6b2d4..68cd21eb 100644 --- a/Sources/JTAppleCollectionReusableView.swift +++ b/Sources/JTAppleCollectionReusableView.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + /// The header view class of the calendar open class JTAppleCollectionReusableView: UICollectionReusableView { /// Initializes and returns a newly allocated view object with the specified frame rectangle. diff --git a/Sources/JTCalendarProtocols.swift b/Sources/JTCalendarProtocols.swift index 8fef3a29..a74d64bf 100644 --- a/Sources/JTCalendarProtocols.swift +++ b/Sources/JTCalendarProtocols.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + /// Default delegate functions public extension JTAppleCalendarViewDelegate { func calendar(_ calendar: JTAppleCalendarView, shouldSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) -> Bool { return true } diff --git a/Sources/UICollectionViewDelegates.swift b/Sources/UICollectionViewDelegates.swift index 41ffed92..ffa1b9b9 100644 --- a/Sources/UICollectionViewDelegates.swift +++ b/Sources/UICollectionViewDelegates.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + extension JTAppleCalendarView: UICollectionViewDelegate, UICollectionViewDataSource { /// Asks your data source object to provide a /// supplementary view to display in the collection view. diff --git a/Sources/UIScrollViewDelegates.swift b/Sources/UIScrollViewDelegates.swift index c81f3ea1..17f4d4f3 100644 --- a/Sources/UIScrollViewDelegates.swift +++ b/Sources/UIScrollViewDelegates.swift @@ -22,6 +22,8 @@ // THE SOFTWARE. // +import UIKit + extension JTAppleCalendarView: UIScrollViewDelegate { /// Inform the scrollViewDidEndDecelerating /// function that scrolling just occurred diff --git a/Sources/UserInteractionFunctions.swift b/Sources/UserInteractionFunctions.swift index 21b3d6dc..98bb8fe3 100644 --- a/Sources/UserInteractionFunctions.swift +++ b/Sources/UserInteractionFunctions.swift @@ -22,6 +22,7 @@ // THE SOFTWARE. // +import UIKit extension JTAppleCalendarView { diff --git a/Tests/JTAppleCalendar_iOSTests.swift b/Tests/JTAppleCalendar_iOSTests.swift index 9f0f2334..8c029aa3 100644 --- a/Tests/JTAppleCalendar_iOSTests.swift +++ b/Tests/JTAppleCalendar_iOSTests.swift @@ -9,7 +9,7 @@ import XCTest @testable import JTAppleCalendar -class JTAppleCalendar_iOSTests: XCTestCas(width, cellSize.height)e { +class JTAppleCalendar_iOSTests: XCTestCase { let calendarView = JTAppleCalendarView() let formatter: DateFormatter = { let aFormatter = DateFormatter()