Search code examples
iosxcodecocoapodsreachabilityswift2

ReachabilitySwift pod causes an error in Swift 2.3


I'm using ReachabilitySwift cocoapods in project.

Pod file :

pod 'ReachabilitySwift', '~> 2.4'

I installed this pod and imported ReachabilitySwift file.

Now, when creating an instance let reachability = Reachability()! results in error Cannot invoke initializer for type 'Reachability' with no arguments.

Screenshot

I tried this solution but didn't worked.

Any fix?


Solution

  • Got the fix!

    Reachability instance to be created as follow for Swift 2.3

    let reachability = try! Reachability.init(hostname: "www.google.com")