Dylan Erskine Dylan Erskine - 12 days ago 6
Swift Question

Facebook SDK not working swift 3

Apparently swift 3 support has been added to the Facebook SDK, but when I try to add it using pods I get the error "Convert to current Swift syntax", any help would be appreciated.

This is the error I get after opening the workspace after running "pod install":

The xcode error after opening the xcode work space

This is what is in my pod file:

enter image description here

Answer

Facebook said they would release swift 3.0 support when swift reaches GM, so if it is available, this would be the way to go. Otherwise their Github page do have Swift 3.0...though in beta. Facebook Swift 3.0 Github

First update your local specs repo by doing this:

Pod repo update

Then in your pod file do:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

target 'Project' do
dynamic frameworks
use_frameworks!

# Pods for Project
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'


post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '3.0'
    end
  end
end
end

Then install the pod

Pod install

Edit:

The last lines post_install do |installer| basically goes through all the frameworks added and makes the pod ask for the swift 3.0 version instead of the default version.