Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Swift 3 Support #53

Closed
rromanchuk opened this issue Sep 8, 2016 · 24 comments
Closed

Swift 3 Support #53

rromanchuk opened this issue Sep 8, 2016 · 24 comments
Assignees

Comments

@rromanchuk
Copy link

No description provided.

@nlutsenko nlutsenko changed the title Swift3 Swift 3 Support Sep 8, 2016
@nlutsenko nlutsenko self-assigned this Sep 8, 2016
@nlutsenko nlutsenko added the enhancement Adds a feature or improvement label Sep 8, 2016
@no-donut-for-you
Copy link

+1

@rromanchuk
Copy link
Author

hey community, is anyone using a known swift3 fork? Has anyone tried running through the conversion tool for this project yet?

@guitcastro
Copy link

@rromanchuk I saw that you forked the project and created the branch swift3, it's working ?

@rromanchuk
Copy link
Author

@guitcastro i gave it a try, but couldn't get it to build. I don't know the project very well so I gave up as i'm too busy right now to debug this SDK. I'm just ripping this out for now.

@gerbiljames
Copy link

I've got a working Swift 3 branch here, it compiles and runs the sample app but Facebook login won't work on iOS 10 (it works fine on iOS 9.3 and lower) due to this bug. I don't have a personal Apple developer account to use to enable keychain sharing for the workaround but I guess that would fix the issue on iOS 10.

@woolfel
Copy link

woolfel commented Sep 14, 2016

definitely don't try auto convert, cuz it doesn't build. I just gave it a try since apple pushed out the latest XCode. Tons of compile errors and general breakage.

@woolfel
Copy link

woolfel commented Sep 14, 2016

Nasty surprise for anyone that upgrades XCode to the latest. Even if you don't upgrade (ie convert to swift 3), you won't be able to build your app. I tried setting swift legacy setting in build settings, but the pod doesn't have the setting. Anyone know of a work around for building the pods with legacy swift?

@woolfel
Copy link

woolfel commented Sep 14, 2016

the fix is to add

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configuration.each do |configuration|
configuration.build_settings['SWIFT_VERSION'] = "2.3"
end
end
end

then run "pods install" to update the workspace. Close the workspace, re-open, clean and build.

@EvsenevDev
Copy link

what about swift 3.0 and Carthage?
I have error:
Module compiled with Swift 2.3 cannot be imported in Swift 3.0

@woolfel
Copy link

woolfel commented Sep 16, 2016

until Facebook officially supports swift 3.0, I would advise sticking with 2.3 and update the podfile settings. I tried auto-convert and it blew up horribly. That wasted about 4 hours on wednesday that I'll never get back.

@goufo
Copy link

goufo commented Sep 17, 2016

+1

@tengpeng
Copy link

tengpeng commented Sep 17, 2016

@gerbiljames Is your sample app written in Swift 3.0?

Can you upload your sampleapp.xcworkspace? I have a developer account and I could enable keychain sharing.

@tengpeng
Copy link

@woolfel I am using Xcode 8 (not beta), and I find the legacy setting in pod building setting.

@tengpeng
Copy link

@EvsenevDev There is also a linkage error if your pod and your app are of different swift versions.

ld: /Users/pt/Library/Developer/Xcode/DerivedData/CurrencyConverter2-diotrdjqfqffqmflbycftzwsojvd/Build/Products/Debug-iphonesimulator/FacebookCore/FacebookCore.framework/FacebookCore compiled with older version of Swift language (2.0) than previous files (3.0) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@woolfel
Copy link

woolfel commented Sep 17, 2016

I'm using version 8 (8A218a) to be exact.

  1. click on your project
  2. change from general to Build settings
  3. type in Swift in the search box
  4. you should see "swift compiler - Version
  5. under that grouping there should be "Use Legacy Swift Language Version"
  6. set it to Yes
  7. clean and build

That's should set your project to use swift 2.3. You still need to update your podfile to update the facebook sdk to use swift 2.3. If you don't update the podfile and run pods install, the facebook projects won't use swift 2.3 and you'll get build errors. hope that helps

@EvsenevDev
Copy link

@woolfel with Swift 2.3 all ok. I think we speak about Swift 3.0. Swift 3.0 not support module compiled in Swift 2.3. Faceebook SDK works with Swift 2.3. Project on Swift 3.0 cant work with facebook sdk. For example, if you want use Alamofire => 4.0.0 (support Swift 3.0) and FacebookSDK, your project cant build.

@gerbiljames
Copy link

@tengpeng It's just the sample app in the fork I linked, translated it to Swift 3 as well when I translated the library.

@gerbiljames
Copy link

gerbiljames commented Sep 18, 2016

I've got a PR open for Swift 3 support at #55. As of yet doesn't seem to have been looked at.

My advice to anyone wanting to use Xcode 8 would be to use Swift 2.3 for now, I've had no trouble with CocoaPods 1.1.0.rc.2, it seems to set Use Legacy Swift Language Version to Yes on all Pod targets which contain Swift by default.

@woolfel
Copy link

woolfel commented Sep 18, 2016

@EvsenevDev - I didn't have any luck with XCode auto-convert from 2.3 to 3.0. As gerbiljames says, if you really need Swift 3.0 due to other libraries/dependencies, you're out of luck.

My project doesn't use any other libraries that requires 3.0, so I'm ok with 2.3 for now.

@tengpeng
Copy link

@gerbiljames Found it! I am having trouble getting the Pod work.

My Podfile

# Uncomment this line to define a global platform for your project
platform :ios, ’10.0’

target 'Pods/Target Support Files/Pods-SwiftCatalog/Pods-SwiftCatalog.debug.xcconfig' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  use_frameworks!

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

end

[!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `SwiftCatalog` to `Pods/Target Support Files/Pods-SwiftCatalog/Pods-SwiftCatalog.debug.xcconfig` or include the `Pods/Target Support Files/Pods-SwiftCatalog/Pods-SwiftCatalog.debug.xcconfig` in your build configuration (`Configurations/SwiftCatalog.xcconfig`).

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target `SwiftCatalog` to `Pods/Target Support Files/Pods-SwiftCatalog/Pods-SwiftCatalog.release.xcconfig` or include the `Pods/Target Support Files/Pods-SwiftCatalog/Pods-SwiftCatalog.release.xcconfig` in your build configuration (`Configurations/SwiftCatalog.xcconfig`).

@gerbiljames
Copy link

@tengpeng The sample project in that repo isn't set up for CocoaPods. I've made an example which is here.

@sevenb
Copy link

sevenb commented Sep 18, 2016

Unfortunately, I had to install a lower version of Alomofire to work.

source 'https://github.com/CocoaPods/Specs.git'

target 'Test' do

Comment this line if you're not using Swift and don't want to use dynamic frameworks

use_frameworks!

pod 'Alamofire', '~> 3.0'
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'

end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
configuration.build_settings['SWIFT_VERSION'] = "2.3"
end
end
end

@realmike33
Copy link

realmike33 commented Sep 18, 2016

I was able to successfully get Facebook to work with Swift 3 by just using their Objective-c pod. You'll also need to change your build options in your project to $(inherited) for Always Embed Swift Standard Libraries and also allow Keychain sharing in the capabilities menu of your xcode project:

use_frameworks!

platform :ios, '10.0'

def available_pods
pod 'FBSDKCoreKit', '~> 4.15.1'
pod 'FBSDKShareKit', '~> 4.15.1'
pod 'FBSDKLoginKit', '~> 4.15.1'
end

@nlutsenko
Copy link
Member

Hey guys,

Sorry for quite a delay in updating to Swift 3.0, got tangled in few other things/projects.

I am going to take a look at the #55 tomorrow morning in detail and either accept/leave review or, most likely, just re-run the migration and update everything in the repo for Swift 3.0 with a new PR, so we can move fast 😁

After that, do a round of testing and update the sample app that we've got.
And finally release the Swift 3.0 version.

Long story short: Expect an update sometime next week or so for Swift 3.0.

@nlutsenko nlutsenko removed the enhancement Adds a feature or improvement label Sep 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests