iosswiftcocoapodsreachabilityreachability-swift

Using Reachability in Swift 5


I followed this tutorial to try and get Reachability installed and usable in my project (https://medium.freecodecamp.org/how-to-handle-internet-connection-reachability-in-swift-34482301ea57)

It states it's all installed but I still get an error on my Import statement.

The images below show the Podfile, the pod install process, the project target name and the error.

Any ideas what I'm missing? I need to detect connection type (3G, 4G, Wifi etc.)

NetworkStatus.swift header

import Foundation
import Reachability //No such module 'Reachability'

Podfile

Dans-MacBook-Pro:gnccapp danpalmer$ cat Podfile
# Uncomment the next line to define a global platform for your project
  platform :ios, '12.2'

target 'gnccapp' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for gnccapp
  pod 'ReachabilitySwift'
  pod 'Alamofire'

end

Installation process of Pods

Dans-MacBook-Pro:gnccapp danpalmer$ pod install
Analyzing dependencies
Setting up CocoaPods master repo
  $ /usr/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
  Cloning into 'master'...
  remote: Enumerating objects: 317, done.        
  remote: Counting objects: 100% (317/317), done.        
  remote: Compressing objects: 100% (256/256), done.        
  remote: Total 3118566 (delta 105), reused 136 (delta 45), pack-reused 3118249        
  Receiving objects: 100% (3118566/3118566), 646.21 MiB | 1.59 MiB/s, done.
  Resolving deltas: 100% (1856966/1856966), done.
  Checking out files: 100% (326428/326428), done.

CocoaPods 1.7.0.rc.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.7.0.rc.1

Setup completed
Downloading dependencies
Installing ReachabilitySwift (4.3.1)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `GNCC.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] Automatically assigning platform `ios` with version `12.2` on target `gnccapp` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Dans-MacBook-Pro:gnccapp danpalmer$ ls -l
total 16
drwxr-xr-x@  6 danpalmer  staff  192 May  6 11:50 GNCC.xcodeproj
drwxr-xr-x   3 danpalmer  staff   96 May  6 11:46 GNCC.xcworkspace
-rw-r--r--   1 danpalmer  staff  279 May  6 11:35 Podfile
-rw-r--r--   1 danpalmer  staff  309 May  6 11:46 Podfile.lock
drwxr-xr-x   8 danpalmer  staff  256 May  6 11:46 Pods
drwxr-xr-x   4 danpalmer  staff  128 May  3 10:39 fonts
drwxr-xr-x  20 danpalmer  staff  640 May  6 11:52 gnccapp
Dans-MacBook-Pro:gnccapp danpalmer$ vi Podfile
Dans-MacBook-Pro:gnccapp danpalmer$ pod install
Analyzing dependencies
Downloading dependencies
Installing Alamofire (4.8.2)
Using ReachabilitySwift (4.3.1)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.

Solution

  • Make sure that you're opening the file that ends in .xcworkspace and not .xcodeproj