Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Swift Package Manager #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ xcuserdata/

# Swift Package Manager
.build/
Package.resolved

# CocoaPods
Pods/
Expand Down
32 changes: 32 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version:4.0

//
// Copyright (c) 2017. Uber Technologies
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import PackageDescription

let package = Package(
name: "RIBs",
products: [
.library(name: "RIBs", targets: ["RIBs"])
],
dependencies : [
.package(url: "https://github.com/ReactiveX/RxSwift", from: "4.0.0")
],
targets: [
.target(name: "RIBs", dependencies: ["RxSwift"], path: "ios/RIBs")
]
)
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ To integrate RIBs into your project using Carthage add the following to your `Ca
github "uber/RIBs" ~> 0.9
```

#### Swift Package Manager

To integrate RIBs into your project using Swift Package Manager add the following to your `Package.swift`:

```swift
dependencies: [
.package(url: "https://github.com/uber/RIBs.git", from: "0.9.0"),
]
```

## License

Copyright (C) 2017 Uber Technologies
Expand Down
2 changes: 2 additions & 0 deletions ios/RIBs/Classes/DI/Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
//

import Foundation

/// The base class for all components.
///
/// A component defines private properties a RIB provides to its internal `Router`, `Interactor`, `Presenter` and
Expand Down
1 change: 0 additions & 1 deletion ios/RIBs/Classes/Interactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import Foundation
import RxSwift
import UIKit

/// Protocol defining the activeness of an interactor's scope.
public protocol InteractorScope: class {
Expand Down
4 changes: 4 additions & 0 deletions ios/RIBs/Classes/LaunchRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
//

#if os(iOS)

import UIKit

/// The root `Router` of an application.
Expand Down Expand Up @@ -47,3 +49,5 @@ open class LaunchRouter<InteractorType, ViewControllerType>: ViewableRouter<Inte
load()
}
}

#endif
1 change: 1 addition & 0 deletions ios/RIBs/Classes/LeakDetector/Executor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
//

import Foundation
import RxSwift

public class Executor {
Expand Down
3 changes: 3 additions & 0 deletions ios/RIBs/Classes/LeakDetector/LeakDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
//

import Foundation
import RxSwift

/// Leak detection status.
Expand Down Expand Up @@ -107,6 +108,7 @@ public class LeakDetector {
return handle
}

#if os(iOS)
/// Sets up an expectation for the given view controller to disappear within the given time.
///
/// - parameter viewController: The `UIViewController` expected to disappear.
Expand Down Expand Up @@ -142,6 +144,7 @@ public class LeakDetector {

return handle
}
#endif

// MARK: - Internal Interface

Expand Down
7 changes: 7 additions & 0 deletions ios/RIBs/Classes/ViewControllable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@
// limitations under the License.
//


#if os(iOS)
import UIKit
#endif

/// Basic interface between a `Router` and the UIKit `UIViewController`.
public protocol ViewControllable: class {

#if os(iOS)
var uiviewController: UIViewController { get }
#endif
}

#if os(iOS)
/// Default implementation on `UIViewController` to conform to `ViewControllable` protocol
public extension ViewControllable where Self: UIViewController {

var uiviewController: UIViewController {
return self
}
}
#endif
6 changes: 6 additions & 0 deletions ios/RIBs/Classes/ViewableRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ open class ViewableRouter<InteractorType, ViewControllerType>: Router<Interactor
// MARK: - Internal

override func internalDidLoad() {
#if os(iOS)
setupViewControllerLeakDetection()
#endif

super.internalDidLoad()
}

// MARK: - Private

#if os(iOS)
private var viewControllerDisappearExpectation: LeakDetectionHandle?

private func setupViewControllerLeakDetection() {
Expand All @@ -88,8 +91,11 @@ open class ViewableRouter<InteractorType, ViewControllerType>: Router<Interactor
})
_ = deinitDisposable.insert(disposable)
}
#endif

deinit {
#if os(iOS)
LeakDetector.instance.expectDeallocate(object: viewControllable.uiviewController, inTime: LeakDefaultExpectationTime.viewDisappear)
#endif
}
}