Rodrigo Ruiz Rodrigo Ruiz - 5 months ago 63
Swift Question

Migrate my pod to Swift 4

I created my pod in Swift 3 and now I wanna migrate it to Swift 4.

I've already done the code migration in the Example project (I chose to create an example when running

pod lib create
), but my podspec is still not passing validation.

One of the reasons is that the default cocoapods configuration is compiling it as Swift 3.

The other is that in order to update the dependencies to compile with Swift 4, I need to reference a specific branch, like
, but I couldn't find a way to do that in the podspec.

How can I fix those problems?

Answer Source

As per the CocoaPods: point to a branch in pod spec

You can't use :git and :branch metadata in podspec. It is expected that the :git and :branch metadata will come from the podfile.

If you want to use tags then use like below : RxCocoa/RxSwift for swift 4 tag(4.0.0-beta.0) do |s|
    ###Your code here
    s.dependency 'RxCocoa', '~> 4.0.0-beta.0'
    s.dependency 'RxSwift', '~> 4.0.0-beta.0'

If you want to use branch, then Your podspecis like below : do |s|
    ###Your code here
    s.dependency 'RxSwift'

Your Podfile will be :


target 'YOUR_TARGET' do
    pod 'RxSwift', :git => '', :branch => 'rxswift4.0-swift4.0'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download