Xcode 10 FBSDK 'SDKLoggingBehavior

MattBlack picture MattBlack · Jun 6, 2018 · Viewed 9.3k times · Source

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)
      }
    }
}

Answer

JAL picture JAL · Jun 6, 2018

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.