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
Make Alamofire an optional dependency #34
Conversation
As discussed in #32, this will have to wait until we're ready to require Swift 4.1. For testing "how does this library behave in an Alamofire environment," I was thinking of moving forward with using Carthage to test one environment and CocoaPods to test the other. We can |
I've also updated the version number. I believe this is a backwards incompatible change: users that pulled in this as a dependency and were taking advantage of its Alamofire dependency (as a result) will no longer get that benefit. |
import Foundation | ||
import UIKit | ||
|
||
#if canImport(Alamofire) | ||
import Alamofire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach gathers the separation of Alamofire symbols into one place.
@@ -172,29 +195,29 @@ public class NetworkActivityIndicatorManager { | |||
|
|||
// MARK: - Private - Notification Registration | |||
|
|||
private func registerForNotifications() { | |||
public func registerForNotifications( | |||
requestDidStartNotificationNames: [Notification.Name] = defaultRequestDidStartNotificationNames, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function works particularly well with AFNetworking; you can hook this library up to AFNetworking in one call.
- Cartfile is now Cartfile.private - Alamofire is now a dependency only for tests - Updated travis to use xcode9.3 GM
49d3eff
to
8a964e9
Compare
Looks like Xcode 9.3 has known problems with running tests with iOS 8.4: http://www.openradar.me/39335367 |
After attempting to write tests for this, it has become clear that accomplishing the goal of making Alamofire optional for a single file adds a lot more complexity than makes sense to try to support. The issue boils down to this: in order to ensure that The only way to really ensure that is to declare 2 modes of integration for each dependency manager: 1 podspec/Cartfile that is explicit about the Alamofire dependency and 1 that declare no dependency. For Carthage, that may not even be possible to do in one repo; because Carthage picks up the Cartfile at the root of the repo, maintaining a separate fork (forgive my lack of Carthage knowledge if there's something I missed there) may be required. The actual lines of Swift here seem simple enough, but I think the maintenance burden this adds is too high. I'm going to close this PR and issue. Thanks for entertaining this! |
Issue Link π
This fixes #32, making Alamofire optional.
Goals β½
Implementation Details π§
#if canImport
to conditionallyimport Alamofire
and setup the default notification listening behavior that is currently used by Alamofire users.Testing Details π