2

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?

Rodrigo Ruiz
  • 4,248
  • 6
  • 43
  • 75

1 Answers1

2

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
Vini App
  • 7,339
  • 2
  • 26
  • 43
  • I'm not sure I follow, where do I put the `Podfile`? I've never seen a pod with a `Podfile`. The only place I've seen a `Podfile` is in the project that is importing the pods. – Rodrigo Ruiz Sep 25 '17 at 00:36
  • In your project Podfile you have to call the `RxSwift` with branch name. – Vini App Sep 25 '17 at 00:39
  • I don't have a `Podfile` in the pod project (the project that creates the pod) – Rodrigo Ruiz Sep 25 '17 at 00:39
  • Here is my pod: https://github.com/rodrigoruiz/SwiftUtilities. Ignore the `Example` folder. – Rodrigo Ruiz Sep 25 '17 at 00:41
  • You wrote like this right "The only place I've seen a Podfile is in the project that is importing the pods.". In this file you have to write. – Vini App Sep 25 '17 at 00:41
  • Maybe I didn't understand you correctly, but I'm not creating a project using pods, I'm creating a pod, so I'm not the one specifying stuff in a `Podfile`. In other words, the user of my pod won't even know he's using `RxSwift`, he will only import my `SwiftUtilities` pod and nothing else. – Rodrigo Ruiz Sep 25 '17 at 00:43
  • Updated the answer. Please check. – Vini App Sep 25 '17 at 00:58
  • Thank you. I still didn't understand the `Podfile` part of your answer, but placing the tag there worked! I also needed the `.swift-version`, just for the record, in case someone else look at this answer. – Rodrigo Ruiz Sep 25 '17 at 01:32