Rodrigo Ruiz Rodrigo Ruiz - 28 days ago 11
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
RxSwift
, 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)

Pod::Spec.new do |s|
    ###Your code here
    s.dependency 'RxCocoa', '~> 4.0.0-beta.0'
    s.dependency 'RxSwift', '~> 4.0.0-beta.0'
end

If you want to use branch, then Your podspecis like below :

Pod::Spec.new do |s|
    ###Your code here
    s.dependency 'RxSwift'
end

Your Podfile will be :

use_frameworks!

target 'YOUR_TARGET' do
    pod 'RxSwift', :git => 'https://github.com/ReactiveX/RxSwift.git', :branch => 'rxswift4.0-swift4.0'
end