Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 4 Cocoapods Issue (How to Fix) #470

Closed
jeco1996 opened this issue Sep 28, 2017 · 13 comments
Closed

Swift 4 Cocoapods Issue (How to Fix) #470

jeco1996 opened this issue Sep 28, 2017 · 13 comments

Comments

@jeco1996
Copy link

jeco1996 commented Sep 28, 2017

Lock Error/warnings on project from scratch and already advanced project..
I had project I was building, since I moved today from swift 3 to swift 4(today I installed xcode 9), Lock framework failed to compile.

I gave it a try on a fresh project(from scratch, whose only has one view controller and the only frameworks that it has is Lock and Auth0) and it failed again, so I have realized it is not something about the project itself but maybe incompatibility with swift 4 and xcode 9. ( I am using Lock 2.4.9, and Auth0 1.8)

image

@cocojoe
Copy link
Member

cocojoe commented Sep 29, 2017

The latest Lock 2.4.0 is compatible with Xcode 9 in the sense it will compile as Swift 3.2 lib while your main project is Swift 4.0 and it's absolutely fine to mix.

The problem here (I'm guessing you're using Cocoapods as there is no issue with carthage ) is the Cocoapods will force the pods to become the Swift version of your project which is 4.0. You can read about this here CocoaPods/CocoaPods#6791

There is thankfully a workaround, add the post_install step to the end of your Podfile.

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

target 'myapp' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for myapp
  pod 'Lock', '~>2.4'
  pod 'Auth0', '~>1.8'

end

post_install do |installer|
  # List of Pods to use as Swift 3.2
  myTargets = ['Lock']

  installer.pods_project.targets.each do |target|
    if myTargets.include? target.name
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '3.2'
      end
    end
  end
end

I'll leave this ticket open for others to see.

@cocojoe cocojoe changed the title Lock compability with Swift 4? Swift 4 Cocoapods Issue Sep 29, 2017
@jeco1996
Copy link
Author

Awesome! Thank you very much guys!

@cocojoe cocojoe changed the title Swift 4 Cocoapods Issue Swift 4 Cocoapods Issue (How to Fix) Sep 29, 2017
@cocojoe
Copy link
Member

cocojoe commented Sep 29, 2017

I'm going to leave it open just now for visibility, perhaps it's worth adding to the README.

@cocojoe cocojoe reopened this Sep 29, 2017
@b-d
Copy link

b-d commented Sep 29, 2017

This fixed the swift 4 errors for me but now I'm getting:

" 'shared' is unavailable: Use view controller based solutions where appropriate instead. "

in Auth0/ControllerModalPresenter

@cocojoe
Copy link
Member

cocojoe commented Sep 29, 2017

@b-d what are you making, it sounds like you are making something that doesn't have a view controller, like an app extension. Please create a new issue and provide sample code. I don't believe this is a Swift 4 related issue. Thx

@helloniklas
Copy link

v 1.9 gives me

Cannot convert value of type '(_) -> ()' to expected argument type 'SFAuthenticationSession.CompletionHandler' (aka '(Optional<URL>, Optional<Error>) -> ()')

This fix does not seem to solve it.

@cocojoe
Copy link
Member

cocojoe commented Oct 20, 2017

I imagine you probably have to deintegrate the pod and reinstall for an existing project vs a new one.
So I just quickly checked this, you can also update setting in the existing Xcode project.
Set to Swift 3.2

screen shot 2017-10-20 at 13 04 11

@nderkach
Copy link

Any plans to upgrade the code to Swift 4?

@cocojoe
Copy link
Member

cocojoe commented Nov 29, 2017

Yes, along with some other bigger changes so keep an eye out.

@adolfo
Copy link
Contributor

adolfo commented Dec 7, 2017

@cocojoe Any update on Swift 4 release timeframe? We are currently blocked from updating our own pod to Swift 4 since you can't lint mixed podspecs and we have Lock as a dependency.

@cocojoe
Copy link
Member

cocojoe commented Dec 7, 2017

@adolfo

  1. This may be fixed in Cocoapods 1.4 (beta), I read they were addressing the issue of mixed pods, although it may just be for installation of pods vs lib functionality.
  2. You could also fork and migrate to Swift 4, it's not so bad.
  3. Lock 3.x will have a complete redesign, I can not give you a timeframe on an official release. However, if possible I would like to see a beta release towards the end of the month.

@cocojoe
Copy link
Member

cocojoe commented Dec 18, 2017

There is a PR that adds 3.2/4.0 compatibility, this should negate the above issue. #480

@adolfo We will release early this week, if you want to try out this branch and feedback that would be great.

@adolfo
Copy link
Contributor

adolfo commented Dec 18, 2017

@cocoojoe thank you, I’ll test it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants