通过可可豆荚安装第三方框架后,使用歧义的'reachabilityChanged'错误?

问题描述 投票:1回答:1

我有以下Internet连接检查代码,使用可重用性来通知我的应用程序中的Internet连接状态何时更改。

self.reachability = Reachability.forInternetConnection();
self.reachability.startNotifier();
NotificationCenter.default.addObserver(self, selector: #selector(self.checkForReachability(notification:)), name: Notification.Name.reachabilityChanged, object: reachability)

在通过可可豆荚添加第三方框架之前,它工作正常,但出现以下错误。不确定使用'reachabilityChanged'

如某些网站/博客中所建议,如果我将其更改为以下代码,则该>]

NotificationCenter.default.addObserver(self, selector: #selector(self.checkForReachability(notification:)), name: Notification.Name("reachabilityChanged"), object: nil)

然后解决了错误,但是当内部连接更改时,它不会通知并且不会调用checkForReachability方法。

如何解决此问题。注意:我不知道哪个第三方框架/文件导致此问题

我正在使用Swift 5

以下是我的Pod文件

# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
source "https://gitlab.linphone.org/BC/public/podspec.git"
source "https://github.com/CocoaPods/Specs.git"

def basic_pods
  if ENV['PODFILE_PATH'].nil?
    pod 'linphone-sdk/basic-frameworks', '> 4.3.0-alpha'
    else
    pod 'linphone-sdk/basic-frameworks', :path => ENV['PODFILE_PATH']  # loacl sdk
  end

  if not ENV['USE_CRASHLYTHICS'].nil?
    # activate crashlythics
    pod 'Firebase/Core'
    pod 'Fabric', '~> 1.9.0'
    pod 'Crashlytics', '~> 3.12.0'
    pod 'Firebase/Performance'

  end
end

target ‘ProjectNameTests' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

  # Pods for liblinphoneTester
  basic_pods

  target 'ProjectNameUITests' do
    inherit! :search_paths
    # Pods for testing
  end

end

target 'ProjectName' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

  # Pods for linphone
  basic_pods
  pod 'SVProgressHUD'
  pod 'Alamofire'
  pod 'SwiftyJSON'
  pod 'IQKeyboardManagerSwift'
  pod 'Kingfisher'
  pod 'MBProgressHUD'
  pod 'SCNetworkReachability'
  pod 'ReachabilitySwift'
  pod 'SideMenu', '~> 6.0'
  pod 'TPKeyboardAvoiding'
  pod "QBImagePickerController"
  pod 'SwiftyContacts'
  pod 'Stripe'
  pod 'BraintreeDropIn'

  #Multiple image selection
  pod 'OpalImagePicker'

  #Firebase
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'


  #pod 'DPOTPView'
  pod 'XMPPFramework'
  #pod 'ReachabilitySwift'
  pod 'SDWebImage', '4.4.7'
  #pod 'GrowingTextView', '0.4'
  pod 'GrowingTextView', '0.7.2'

  pod 'TTTAttributedLabel'
  pod 'GooglePlaces'
  pod 'GooglePlacePicker'
  pod 'GoogleMaps'
  pod 'ReverseExtension', '~> 0.5.0'
  pod 'PlacesPicker'



 # target 'ProjectNameTests' do
    #inherit! :search_paths
    #pod 'KIF', :configurations => ['Debug']
    # Pods for testing
  #end

end


=begin
target 'latestCallsWidget' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

  # Pods for latestCallsWidget

end

target 'latestChatroomsWidget' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

  # Pods for latestChatroomsWidget
end


target 'richNotifications' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

  # Pods for richNotifications

end
=end

post_install do |installer|
  # Get the version of linphone-sdk
  installer.pod_targets.each do |target|
    if target.pod_name == 'linphone-sdk'
      target.specs.each do |spec|
        $linphone_sdk_version = spec.version
      end
    end
  end

  app_project = Xcodeproj::Project.open(Dir.glob("*.xcodeproj")[0])
  app_project.native_targets.each do |target|
    if target.name == 'ProjectName'
      target.build_configurations.each do |config|
        if ENV['USE_CRASHLYTHICS'].nil?
          if config.name == "Debug" then
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) DEBUG=1'
          else
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited)'
          end
        else
          # activate crashlythics
          if config.name == "Debug" then
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) DEBUG=1 USE_CRASHLYTHICSS=1'
            else
            config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited) USE_CRASHLYTHICSS=1'
          end
        end

        config.build_settings['OTHER_CFLAGS'] = '-DBCTBX_LOG_DOMAIN=\"ios\"',
                                                '-DCHECK_VERSION_UPDATE=FALSE',
                                                '-DENABLE_QRCODE=TRUE',
                                                '-DENABLE_SMS_INVITE=TRUE',
                                                '$(inherited)',
                                                "-DLINPHONE_SDK_VERSION=\\\"#{$linphone_sdk_version}\\\""

        app_project.save
      end
    end
  end
end

我有以下互联网连通性检查代码,使用可重用性来通知我的应用程序中的互联网连接状态何时发生更改。 self.reachability = Reachability.forInternetConnection();自我....

ios swift nsnotificationcenter reachability
1个回答
0
投票

[当我将ReachabilitySwift Pod库文件中的通知reachabilityChanged名称更改为其他名称时,我没有收到构建错误,并且当网络状态更改时,也调用了checkForReachability方法。

© www.soinside.com 2019 - 2024. All rights reserved.