Skip to content

Commit 953ff50

Browse files
M0rtyMerrtwittemb
authored andcommitted
Add SPM support (#125)
* Add SPM support * Remove tvOS and macOS * Fix SPM test
1 parent 5ba220b commit 953ff50

19 files changed

+83
-2
lines changed

.circleci/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ jobs:
2828
- run:
2929
name: Run Tests (Swift 5)
3030
command: set -o pipefail && xcodebuild test SWIFT_VERSION=5.0 -scheme 'RxFlow' -project 'RxFlow.xcodeproj' -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/iOS_Swift5.html
31+
- run:
32+
name: Run Tests SPM
33+
command: swift test
3134
- store_artifacts:
3235
path: /tmp/xcode-test-results
3336
workflows:

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ fastlane/report.xml
7070
fastlane/Preview.html
7171
fastlane/screenshots
7272
fastlane/test_output
73+
74+
.idea
75+
Package.resolved
76+
.swiftpm

Package.swift

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// swift-tools-version:5.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "RxFlow",
7+
platforms: [.iOS(.v9)],
8+
products: [
9+
.library(name: "RxFlow", targets: ["RxFlow"]),
10+
],
11+
dependencies: [
12+
.package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "5.0.0")),
13+
],
14+
targets: [
15+
.target(name: "RxFlow", dependencies: ["RxSwift", "RxCocoa"], path: "RxFlow"),
16+
.testTarget(name: "RxFlowTests", dependencies: ["RxFlow", "RxBlocking", "RxTest"], path: "RxFlowTests"),
17+
],
18+
swiftLanguageVersions: [.v5]
19+
)

RxFlow/Extensions/Rx+Pausable.swift

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import RxSwift
10+
import Foundation
1011

1112
// this code had been inspired by the project: https://github.com/RxSwiftCommunity/RxSwiftExt
1213
// Its License can be found here: ../DependenciesLicenses/RxSwiftCommunity-RxSwiftExt-License

RxFlow/Extensions/UIViewController+Presentable.swift

+3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// Copyright (c) RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit.UIViewController
1011
import RxSwift
1112

1213
extension UIViewController: Presentable {}
14+
15+
#endif

RxFlow/Extensions/UIViewController+Rx.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// this code had been inspired by the project: https://github.com/devxoul/RxViewController
1010
// Its License can be found here: ../DependenciesLicenses/devxoul-RxViewController-License
11-
11+
#if canImport(UIKit)
1212
import UIKit.UIViewController
1313
import RxSwift
1414
import RxCocoa
@@ -39,3 +39,5 @@ extension Reactive where Base: UIViewController {
3939
return initialState.concat(Observable<Bool>.merge(viewDidAppearObservable, viewDidDisappearObservable))
4040
}
4141
}
42+
43+
#endif

RxFlow/Extensions/UIWindow+Presentable.swift

+3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// Copyright (c) RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit.UIWindow
1011
import RxSwift
1112

1213
extension UIWindow: Presentable {}
14+
15+
#endif

RxFlow/Extensions/UIWindow+Rx.swift

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright (c) RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
import UIKit
1011
import RxSwift
1112

@@ -17,3 +18,5 @@ extension Reactive where Base: UIWindow {
1718
}
1819

1920
}
21+
22+
#endif

RxFlow/Flow.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright (c) RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
10+
911
import RxSwift
1012
import RxCocoa
1113
import UIKit
@@ -233,3 +235,5 @@ public class Flows {
233235
})
234236
}
235237
}
238+
239+
#endif

RxFlow/FlowContributor.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright (c) RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
10+
911
/// A FlowContributor describes the next thing that will contribute to a Flow.
1012
///
1113
/// - contribute: the given stepper will emit steps (according to lifecycle of the given presentable) that will contribute to the current Flow
@@ -54,3 +56,5 @@ public enum FlowContributors {
5456
@available(*, deprecated, message: "You should use .one(flowContributor: .forwardToParentFlow(withStep: Step))")
5557
case triggerParentFlow (withStep: Step)
5658
}
59+
60+
#endif

RxFlow/FlowCoordinator.swift

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// Created by Thibault Wittemberg on 2018-12-19.
66
// Copyright © 2018 RxSwiftCommunity. All rights reserved.
77
//
8+
9+
#if canImport(UIKit)
10+
import Foundation
811
import RxSwift
912
import RxCocoa
1013

@@ -203,3 +206,5 @@ private class PresentableAndStepper {
203206
self.stepper = stepper
204207
}
205208
}
209+
210+
#endif

RxFlow/Presentable.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
// Copyright (c) RxSwiftCommunity. All rights reserved.
77
//
88

9-
import UIKit.UIViewController
9+
#if canImport(UIKit)
1010

11+
import UIKit.UIViewController
1112
import RxSwift
1213

1314
/// An abstraction of what can be presented to the screen. For now, UIViewControllers and Flows are Presentable
@@ -59,3 +60,5 @@ extension Presentable where Self: UIWindow {
5960
return Single.never()
6061
}
6162
}
63+
64+
#endif

RxFlow/Synchronizable.swift

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
// this code had been inspired by the project: https://github.com/RxSwiftCommunity/NSObject-Rx
1010
// Its License can be found here: ../DependenciesLicenses/RxSwiftCommunity-NSObject-Rx-License
1111

12+
#if canImport(ObjectiveC)
13+
import ObjectiveC
14+
1215
/// Provides a function to prevent concurrent block execution
1316
public protocol Synchronizable {}
1417

@@ -20,3 +23,5 @@ extension Synchronizable {
2023
return result
2124
}
2225
}
26+
27+
#endif

RxFlowTests/Flow+PresentableTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2019 RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
10+
911
@testable import RxFlow
1012
import XCTest
1113
import RxBlocking
@@ -67,3 +69,5 @@ final class Flow_PresentableTests: XCTestCase {
6769
XCTAssertEqual(observer.events.count, 2)
6870
}
6971
}
72+
73+
#endif

RxFlowTests/FlowContributorTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// Copyright © 2019 RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
910
@testable import RxFlow
1011
import RxRelay
1112
import RxSwift
@@ -35,3 +36,4 @@ final class FlowContributorTests: XCTestCase {
3536
}
3637
}
3738
}
39+
#endif

RxFlowTests/FlowCoordinatorTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2019 RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
10+
911
@testable import RxFlow
1012
import XCTest
1113
import RxBlocking
@@ -80,3 +82,5 @@ final class FlowCoordinatorTests: XCTestCase {
8082
XCTAssertEqual(actualSteps, [.multiple, .one, .two])
8183
}
8284
}
85+
86+
#endif

RxFlowTests/SyncronizableTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2018 RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if os(iOS) || os(macOS)
10+
911
import XCTest
1012
@testable import RxFlow
1113

@@ -71,3 +73,5 @@ final class SyncronizableTests: XCTestCase {
7173

7274
}
7375
}
76+
77+
#endif

RxFlowTests/TestData/TestUIViewController.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2018 RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
10+
911
import UIKit
1012
import Reusable
1113

@@ -14,3 +16,5 @@ final class TestUIViewController: UIViewController, StoryboardBased {
1416
super.viewDidLoad()
1517
}
1618
}
19+
20+
#endif

RxFlowTests/UIViewController+PresentableTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright © 2018 RxSwiftCommunity. All rights reserved.
77
//
88

9+
#if canImport(UIKit)
10+
911
@testable import RxFlow
1012
import XCTest
1113
import RxBlocking
@@ -55,3 +57,5 @@ final class UIViewController_PresentableTests: XCTestCase {
5557
XCTAssertEqual(observer.events.count, 2)
5658
}
5759
}
60+
61+
#endif

0 commit comments

Comments
 (0)