From cd1c75bc1b72b7a7224ad8e8197b97d367aadbcf Mon Sep 17 00:00:00 2001 From: janlionly Date: Mon, 29 Jun 2020 15:46:02 +0800 Subject: [PATCH] Support for Swift Package Manager --- .../contents.xcworkspacedata | 7 ++++ Package.swift | 33 ++++++++++++++++--- README.md | 7 ++++ Tests/LinuxMain.swift | 7 ++++ Tests/SwiftyTimerTests/SwiftyTimerTests.swift | 15 +++++++++ Tests/SwiftyTimerTests/XCTestManifests.swift | 9 +++++ 6 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata create mode 100644 Tests/LinuxMain.swift create mode 100644 Tests/SwiftyTimerTests/SwiftyTimerTests.swift create mode 100644 Tests/SwiftyTimerTests/XCTestManifests.swift diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Package.swift b/Package.swift index 507af30..976345f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,8 +1,31 @@ +// swift-tools-version:5.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + import PackageDescription let package = Package( - name: "SwiftyTimer", - dependencies: [], - exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h", "SwiftyTimerTests"] - -) \ No newline at end of file + name: "SwiftyTimer", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "SwiftyTimer", + targets: ["SwiftyTimer"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "SwiftyTimer", + dependencies: [], + path: "Sources", + exclude: ["Info.plist", "SwiftyTimer.h"] + ), + .testTarget( + name: "SwiftyTimerTests", + dependencies: ["SwiftyTimer"]), + ] +) diff --git a/README.md b/README.md index cd25710..4283ac0 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,13 @@ Just add to your Cartfile: github "radex/SwiftyTimer" ``` +#### Swift Package Manager +- iOS: Open Xcode, File->Swift Packages, search input **https://github.com/radex/SwiftyTimer.git**, and then select Version Up to Next Major **2.1.1** < . +- Or add dependencies in your `Package.swift`: +```ruby +.package(url: "https://github.com/radex/SwiftyTimer.git", .upToNextMajor(from: "2.1.1")), +``` + #### Manually Simply copy `Sources/SwiftyTimer.swift` to your Xcode project. diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..d4bf36d --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import SwiftyTimerTests + +var tests = [XCTestCaseEntry]() +tests += SwiftyTimerTests.allTests() +XCTMain(tests) diff --git a/Tests/SwiftyTimerTests/SwiftyTimerTests.swift b/Tests/SwiftyTimerTests/SwiftyTimerTests.swift new file mode 100644 index 0000000..f4fcf46 --- /dev/null +++ b/Tests/SwiftyTimerTests/SwiftyTimerTests.swift @@ -0,0 +1,15 @@ +import XCTest +@testable import SwiftyTimer + +final class SwiftyTimerTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(SwiftyTimer().text, "Hello, World!") + } + + static var allTests = [ + ("testExample", testExample), + ] +} diff --git a/Tests/SwiftyTimerTests/XCTestManifests.swift b/Tests/SwiftyTimerTests/XCTestManifests.swift new file mode 100644 index 0000000..37a1bd4 --- /dev/null +++ b/Tests/SwiftyTimerTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(SwiftyTimerTests.allTests), + ] +} +#endif