1

I'm working on iOS app, and the app is currently running on Xcode 7 swift 2.3, and it has cocoa pods dependencies. I'm trying to migrate the app from swift 2 --> swift 4 and update the cocoa pods as while. Every time I try to migrate the app; I receive so many errors messages. I went into the pod file and update each pod in order to support swift 4 no luck. Can anyone help me complete this migrations step by step.

 platform :ios, '9.2'
 use_frameworks!
 pod 'Parse'
 pod 'ParseUI'
 pod 'FBSDKCoreKit'
 pod 'FBSDKLoginKit'
 pod 'FBSDKShareKit'
 pod 'ParseFacebookUtilsV4'
 pod 'GoogleMaps', '~> 1.10.1'
 pod 'Alamofire', '~> 3.2.1'
 pod 'SwiftyJSON', '~> 2.3.0'
 pod 'Onboard'
 pod 'SWRevealViewController'
 pod 'XLForm', '~> 3.1.1'

post_install do |installer|

swift3Targets = [
'Parse'
'ParseUI'
'FBSDKCoreKit'
'FBSDKLoginKit'
'FBSDKShareKit'
'ParseFacebookUtilsV4'
'GoogleMaps'
'Alamofire'
'SwiftyJSON'
'Onboard'
'SWRevealViewController'
'XLForm'
]
   installer.pods_project.targets.each do |target|
   if swift3Targets.include? target.name
   target.build_configurations.each do |config|
   config.build_settings['SWIFT_VERSION'] = '3.0'
   end
  end
  end

   # Workaround for Cocoapods issue #7606
    installer.pods_project.build_configurations.each do |config|
    config.build_settings.delete('CODE_SIGNING_ALLOWED')
   config.build_settings.delete('CODE_SIGNING_REQUIRED')
   end

    installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
    if config.name == 'Debug'
    config.build_settings['OTHER_SWIFT_FLAGS'] = ['$(inherited)', '-   Onone']
   config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule'
end

end end end

 Will my pod file look like this? I migrated my code from swift 2.3 --> swift 3
Shivam Tripathi
  • 1,405
  • 3
  • 19
  • 37
Greg Jones
  • 11
  • 2

1 Answers1

1

You don't need to update all cocoapods at once. I suggest keeping them at the old version and just migrating your own code first. Then you can still migrate them one pod at a time. We're still doing the same with Swift 3 as not all pods are supporting newer versions of Swift:

At the end of our Pod file we added something like this:

post_install do |installer|

 swift3Targets = [
    'Sugar',
    'SQLite.swift',
    'SwiftyJSON',
    'Walker',
 ]

 installer.pods_project.targets.each do |target|
    if swift3Targets.include? target.name
       target.build_configurations.each do |config|
       config.build_settings['SWIFT_VERSION'] = '3.2'
    end
  end
end

# Workaround for Cocoapods issue #7606
installer.pods_project.build_configurations.each do |config|
  config.build_settings.delete('CODE_SIGNING_ALLOWED')
    config.build_settings.delete('CODE_SIGNING_REQUIRED')
end

installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    if config.name == 'Debug'
      config.build_settings['OTHER_SWIFT_FLAGS'] = ['$(inherited)', '-Onone']
      config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule'
    end
  end
end
end

Hope that will help you! Also check this link out

Geru
  • 624
  • 1
  • 7
  • 20
  • Hey, so I migrated my code from swift 2.3 to swift 3 and I was wondering will my pod file look like this now: – Greg Jones Aug 05 '18 at 22:36