Swift 4 project that includes a Swift 3 Pod

Is there a way to build a Swift 4 project with Bitrise, but build one of the included pods as Swift 3. One can set the Swift version per Pod in Xcode, but that does not propagate via die repository to Bitrise.

Compiling the entire project as Swift 4 results in an error due to deprecated calls in one included pod.

Hi @jpm_polymorph,

How do you build the project locally? I mean, how do you configure which pod should use which swift version? On a new Mac do you configure this by hand / manually after a pod install?

I’d suggest you to specify the Swift version in your CocoaPods Podfile, instead of doing the toggling manually, as e.g. when a new team member joins your team or you setup a new Mac you won’t have to remember which pods to change, a pod install will take care of it.

It seems CocoaPods will add a “DSL” level feature for this: https://github.com/CocoaPods/CocoaPods/issues/7134

But that’s not available in the current CocoaPods version, but a general “scripted” solution is definitely available (Podfile allows you to script changes on the Pod projects). Example: https://github.com/CocoaPods/CocoaPods/issues/6791#issuecomment-333079766

 post_install do |installer|
        installer.pods_project.targets.each do |target|
            if ['Kingfisher', 'RxSwift', 'RxCocoa'].include? target.name
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = '3.2'
                end
            end
        end
    end

(source: https://github.com/CocoaPods/CocoaPods/issues/6791#issuecomment-333079766)

where 'Kingfisher', 'RxSwift', 'RxCocoa' are the Pods which should be built with Swift 3.2

The Podfile based solution also “just works” on Bitrise / in a CI environment too, as CocoaPods will take care of these Xcode project file changes automatically as part of the pod install process.

You can find more info & examples in the GitHub issue ( https://github.com/CocoaPods/CocoaPods/issues/6791 ) and of course if you’d have any questions feel free to ask! :wink:

1 Like

Oh amazing. Now I really learned something new. I indeed configured it by hand in Xcode every time after I did a pod install. Thanks a lot for this solution! It will save me a lot of trouble.

1 Like

Glad to hear :wink:
Happy Building!