From c379e5fa1c0d68385d9d60e2bfaaaae9ad7f75db Mon Sep 17 00:00:00 2001 From: Harry Shamansky Date: Sat, 28 Dec 2019 14:59:17 -0500 Subject: [PATCH 1/2] Add Swift Package Manager support This commit primarily adds Swift Package Manager support via a new Package.swift file. It also makes a few other cleanups, including: - Swapping Foundation imports with UIKit imports where necessary - Cleaning up unused test files --- ColorPicker.xcodeproj/project.pbxproj | 4 +++ ColorPicker/ColorPickerView.swift | 2 +- ColorPicker/ColorPickerViewDelegate.swift | 2 -- ColorPicker/HSB.swift | 2 +- ColorPicker/RGB.swift | 2 +- ColorPicker/UIColorExtension.swift | 2 +- ColorPickerTests/ColorPickerTests.swift | 34 ----------------------- ColorPickerTests/Info.plist | 22 --------------- Package.swift | 22 +++++++++++++++ README.md | 7 +++++ 10 files changed, 37 insertions(+), 62 deletions(-) delete mode 100644 ColorPickerTests/ColorPickerTests.swift delete mode 100644 ColorPickerTests/Info.plist create mode 100644 Package.swift diff --git a/ColorPicker.xcodeproj/project.pbxproj b/ColorPicker.xcodeproj/project.pbxproj index 005b3cf..c1f3446 100644 --- a/ColorPicker.xcodeproj/project.pbxproj +++ b/ColorPicker.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4A17F36E23B7E58700619791 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A17F36D23B7E58700619791 /* Package.swift */; }; 9668C54C217AE63C0021FC09 /* ColorSpaceConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9668C54B217AE63C0021FC09 /* ColorSpaceConverter.swift */; }; 9668C54E217B0DCD0021FC09 /* ColorPickerViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9668C54D217B0DCD0021FC09 /* ColorPickerViewDelegate.swift */; }; 9668C550217B29BF0021FC09 /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9668C54F217B29BF0021FC09 /* UIColorExtension.swift */; }; @@ -29,6 +30,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 4A17F36D23B7E58700619791 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = SOURCE_ROOT; }; 9668C54B217AE63C0021FC09 /* ColorSpaceConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorSpaceConverter.swift; sourceTree = ""; }; 9668C54D217B0DCD0021FC09 /* ColorPickerViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPickerViewDelegate.swift; sourceTree = ""; }; 9668C54F217B29BF0021FC09 /* UIColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtension.swift; sourceTree = ""; }; @@ -65,6 +67,7 @@ 966E577A217A0A2B009CBABF = { isa = PBXGroup; children = ( + 4A17F36D23B7E58700619791 /* Package.swift */, 966E5786217A0A2B009CBABF /* ColorPicker */, 966E5791217A0A2C009CBABF /* ColorPickerTests */, 966E5785217A0A2B009CBABF /* Products */, @@ -216,6 +219,7 @@ 966E57C8217A1437009CBABF /* ColorPickerView.swift in Sources */, 966E57C1217A12EC009CBABF /* RGB.swift in Sources */, 9668C54E217B0DCD0021FC09 /* ColorPickerViewDelegate.swift in Sources */, + 4A17F36E23B7E58700619791 /* Package.swift in Sources */, 966E57C3217A12F3009CBABF /* HSB.swift in Sources */, 9668C54C217AE63C0021FC09 /* ColorSpaceConverter.swift in Sources */, 9668C550217B29BF0021FC09 /* UIColorExtension.swift in Sources */, diff --git a/ColorPicker/ColorPickerView.swift b/ColorPicker/ColorPickerView.swift index c15707b..b16baf9 100644 --- a/ColorPicker/ColorPickerView.swift +++ b/ColorPicker/ColorPickerView.swift @@ -6,7 +6,7 @@ // Copyright © 2018年 culumn. All rights reserved. // -import Foundation +import UIKit public class ColorPickerView: UIView { diff --git a/ColorPicker/ColorPickerViewDelegate.swift b/ColorPicker/ColorPickerViewDelegate.swift index df6116a..9fb59ad 100644 --- a/ColorPicker/ColorPickerViewDelegate.swift +++ b/ColorPicker/ColorPickerViewDelegate.swift @@ -6,8 +6,6 @@ // Copyright © 2018年 culumn. All rights reserved. // -import Foundation - public protocol ColorPickerViewDelegate: class { func colorPickerWillBeginDragging(_ colorPicker: ColorPickerView) func colorPickerDidSelectColor(_ colorPicker: ColorPickerView) diff --git a/ColorPicker/HSB.swift b/ColorPicker/HSB.swift index 611a51d..0687aff 100644 --- a/ColorPicker/HSB.swift +++ b/ColorPicker/HSB.swift @@ -6,7 +6,7 @@ // Copyright © 2018年 culumn. All rights reserved. // -import Foundation +import UIKit public struct HSB { public var hue: CGFloat diff --git a/ColorPicker/RGB.swift b/ColorPicker/RGB.swift index 254d275..301fd98 100644 --- a/ColorPicker/RGB.swift +++ b/ColorPicker/RGB.swift @@ -6,7 +6,7 @@ // Copyright © 2018年 culumn. All rights reserved. // -import Foundation +import UIKit public struct RGB { public var red: CGFloat diff --git a/ColorPicker/UIColorExtension.swift b/ColorPicker/UIColorExtension.swift index 28943cd..1e5d8c0 100644 --- a/ColorPicker/UIColorExtension.swift +++ b/ColorPicker/UIColorExtension.swift @@ -6,7 +6,7 @@ // Copyright © 2018年 culumn. All rights reserved. // -import Foundation +import UIKit public extension UIColor { diff --git a/ColorPickerTests/ColorPickerTests.swift b/ColorPickerTests/ColorPickerTests.swift deleted file mode 100644 index 0872764..0000000 --- a/ColorPickerTests/ColorPickerTests.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// ColorPickerTests.swift -// ColorPickerTests -// -// Created by Matsuoka Yoshiteru on 2018/10/19. -// Copyright © 2018年 culumn. All rights reserved. -// - -import XCTest -@testable import ColorPicker - -class ColorPickerTests: XCTestCase { - - override func setUp() { - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } - -} diff --git a/ColorPickerTests/Info.plist b/ColorPickerTests/Info.plist deleted file mode 100644 index 6c40a6c..0000000 --- a/ColorPickerTests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..7fbf345 --- /dev/null +++ b/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version:5.1 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "ColorPicker", + platforms: [ + .iOS(.v9) + ], + products: [ + .library( + name: "ColorPicker", + targets: ["ColorPicker"]), + ], + targets: [ + .target( + name: "ColorPicker", + path: "ColorPicker/") + ] +) + diff --git a/README.md b/README.md index 9e2c350..a2412cb 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,13 @@ class ViewController: UIViewController, ColorPickerViewDelegate { To run the example project, open the `Example/Example.xcworkspace`. ## Installation + +### Swift Package Manager +In Xcode 11+, Go to File > Swift Packages > Add Package Dependencies… and paste the following Git URL into the text box: +``` +https://github.com/culumn/ColorPicker +``` + ### [CocoaPods](https://cocoapods.org) ColorPicker is available through [CocoaPods](https://cocoapods.org). To install it, simply add the following line to your `Podfile`: From 6fed79779b29af10d932047d03729c60bf3e8531 Mon Sep 17 00:00:00 2001 From: Harry Shamansky Date: Sat, 28 Dec 2019 15:13:06 -0500 Subject: [PATCH 2/2] Add test stubs back in Add test stubs back in since the lack of tests is documented as #3. This does not add tests to the Swift Package since that seems to require a directory restructure. --- ColorPickerTests/ColorPickerTests.swift | 34 +++++++++++++++++++++++++ ColorPickerTests/info.plist | 22 ++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 ColorPickerTests/ColorPickerTests.swift create mode 100644 ColorPickerTests/info.plist diff --git a/ColorPickerTests/ColorPickerTests.swift b/ColorPickerTests/ColorPickerTests.swift new file mode 100644 index 0000000..0872764 --- /dev/null +++ b/ColorPickerTests/ColorPickerTests.swift @@ -0,0 +1,34 @@ +// +// ColorPickerTests.swift +// ColorPickerTests +// +// Created by Matsuoka Yoshiteru on 2018/10/19. +// Copyright © 2018年 culumn. All rights reserved. +// + +import XCTest +@testable import ColorPicker + +class ColorPickerTests: XCTestCase { + + override func setUp() { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/ColorPickerTests/info.plist b/ColorPickerTests/info.plist new file mode 100644 index 0000000..2d98bea --- /dev/null +++ b/ColorPickerTests/info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + \ No newline at end of file