user1898712
user1898712

Reputation: 368

How to update a cocoapod built in Swift 3 to Swift 4

So I've downloaded the Xcode 9 beta, and I've been tasked with updating one of our in house pods from Swift 3 to Swift 4. I have cloned the repo, and opened it and can see all the project files and everything else, but there is no scheme, and I am unable to use Edit > Convert > Convert to current Swift syntax as it is greyed out.

On the main project, I used the migration tool and then went through manually and added @objc to expose whatever was referenced in Objective-C, but I can't seem to be able to do that with the pod.

I'm just wondering if someone has any experience on updating a pod to Swift 4, and if so how do I go about doing it as there is very little information online about it.

Many thanks as always,

Niall

Upvotes: 0

Views: 3376

Answers (3)

Christopher Rex
Christopher Rex

Reputation: 392

The best way to do this is with a post install hook in your pod file. Otherwise each time you install/update your pods that setting will be changed back

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'ProjectX' do
    pod '_your_pod_'
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.2'
        end 
    end
end

Upvotes: 4

Herakleis
Herakleis

Reputation: 533

Go to your Pods project, then:

  1. Select the target you want to update
  2. Go into its build settings
  3. Select Swift 3.2 as the language version

enter image description here

Upvotes: 6

kcg94
kcg94

Reputation: 11

You can try to change pod language swift4.0 to swift3.2 . It might solve your problem. It can be done in build settings. Search swift and change it.

Upvotes: 1

Related Questions