Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 10 FBSDK 'SDKLoggingBehavior

I have updated to Xcode 10 and and am unable to compile my code. I get the following error from the Facebook SDK (FacebookCore).

Argument type 'SDKLoggingBehavior?' does not conform to expected type 'Sequence'

On line

return Set(behaviors)

I have installed the lastest FBSDK using cocoapods.

How would I go about resolving this or is it a case of waiting for an updated SDK from FB?

extension SDKSettings {
      /**
       Current logging behaviors of Facebook SDK.
       The default enabled behavior is `.DeveloperErrors` only.
       */
      public static var enabledLoggingBehaviors: Set<SDKLoggingBehavior> {
        get {
          let behaviors = FBSDKSettings.loggingBehavior().flatMap { object -> SDKLoggingBehavior? in
            if let value = object as? String {
              return SDKLoggingBehavior(sdkStringValue: value)
            }
            return nil
          }
          return Set(behaviors)
        }
        set {
          let behaviors = newValue.map({ $0.sdkStringValue })
          FBSDKSettings.setLoggingBehavior(Set(behaviors))
        }
      }

      /**
       Enable a particular Facebook SDK logging behavior.

       - parameter behavior: The behavior to enable
       */
      public static func enableLoggingBehavior(_ behavior: SDKLoggingBehavior) {
        FBSDKSettings.enableLoggingBehavior(behavior.sdkStringValue)
      }

      /**
       Disable a particular Facebook SDK logging behavior.

       - parameter behavior: The behavior to disable.
       */
      public static func disableLoggingBehavior(_ behavior: SDKLoggingBehavior) {
        FBSDKSettings.disableLoggingBehavior(behavior.sdkStringValue)
      }
    }
}
like image 469
MattBlack Avatar asked Jun 06 '18 16:06

MattBlack


2 Answers

This is fixed in the latest release, 0.3.1 (as of June 8th, 2018).

Old answer:

This is fixed in the latest master, but not in the latest tag or Cocoapod release.

To use this, clone the code directly from the master branch into your project from the Swift SDK repo, or change your podfile to point to master:

pod 'FacebookCore', :git => 'https://github.com/facebook/facebook-sdk-swift', :branch => 'master'

The pull request that fixed this issue can be found here.

like image 191
JAL Avatar answered Oct 21 '22 10:10

JAL


Adding to @JAL's answer:

For me, installing pods still giving me version 0.3.0

modifying PodFile with latest version number gives me latest sdk

  pod 'FacebookCore','0.5.0'
  pod 'FacebookLogin','0.5.0'
  pod 'FacebookShare','0.5.0'
like image 29
Zaid Mirza Avatar answered Oct 21 '22 10:10

Zaid Mirza