SolvedCocoaPods pod install triggers pods to use Swift 4.2 in XCode 10

[*] I've read and understood the CONTRIBUTING guidelines and have done my best effort to follow.


With Xcode 10, running pod install will force all pods in workspace to use Swift 4.2, even the pod is not built for Swift 4.2. Then the workspace gets into a corrupted state where build errors cannot be removed. I have to delete the whole project and download it from our source control server.

I have tried Cocopods 1.5.3 and 1.6.0.beta.1. Both are behaving the same. Also tried to manually setting all pods back to Swift 4.0 for compilation but didn't help. I have to redownload my repo and AVOID running pod install to make my project run.

P.S. I push all pod files to my version control server.

What did you do?

Run pod install on a working workspace.

What did you expect to happen?

Install all pod dependencies correctly and the workspace should build correctly, just like in Xcode 9.

What happened instead?

'pod install' run successfully. However the workspace could not be built. Some of the pods error as Command CompileSwift failed with a nonzero exit code. Some are reporting to keywords/enums has been renamed in Swift 4.2.

CocoaPods Environment


   CocoaPods : 1.6.0.beta.1
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
    RubyGems :
        Host : Mac OS X 10.13.6 (17G65)
       Xcode : 10.0 (10A255)
         Git : git version 2.17.1 (Apple Git-112)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : facebook - @ 81e1b89b403990c678b79c620da9c0bcf8ff7d89
               master - @ 56daa217b3d0aed57cfcdd255cd1f7548714f396

Installation Source

Executable Path: /usr/local/bin/pod


cocoapods-deintegrate : 1.0.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0
cocoapods-trunk       : 1.3.1
cocoapods-try         : 1.1.0


# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'

# ignore all warnings from all pods

def common_pods
  pod 'Alamofire', '~> 4.5'
  pod 'AlamofireImage', '~> 3.3'
  pod 'AMScrollingNavbar'
  pod 'BetterSegmentedControl', '~> 0.9'
  pod 'Cache', '~> 4.1'
  pod 'Crashlytics'
  pod 'CropViewController'
  pod 'Dollar', '~> 7.1'
  pod 'Fabric'
  pod 'Hero'
  pod 'ImagePicker'
  pod 'Intercom'
  pod 'InteractiveSideMenu'
  pod 'IQKeyboardManagerSwift'
  pod 'Koyomi', :git => ''
  pod 'Mixpanel-swift'
  pod 'MTBBarcodeScanner'
  pod 'netfox'
  pod 'NVActivityIndicatorView'
  pod 'OHHTTPStubs/Swift'
  pod 'PromiseKit', '~> 4.5.2'
  pod 'PromiseKit/Alamofire'
  # pod 'PocketSVG' // Not being used currently but may in future
  pod 'PopupDialog', '~> 0.6'
  pod 'RevealingSplashView'
  pod 'SearchTextField'
  pod 'SkyFloatingLabelTextField', '~> 3.0'
  pod 'Stripe'
  pod 'SwiftKeychainWrapper'
  pod 'SwiftSoup'
  pod 'UPCarouselFlowLayout', :git => ''
  pod 'Validator'
  pod 'RxSwift',    '~> 4.0'
  pod 'RxCocoa',    '~> 4.0'

target 'AAA' do

  pod 'RxDataSources'

target 'AAATests' do
  pod 'Quick'
  pod 'RxNimble'
  pod 'RxBlocking', '~> 4.0'
  pod 'RxTest',     '~> 4.0'

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    # Workaround for CocoaPods issue:
    # Do not need debug information for pods
    config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
    # Disable Code Coverage for Pods projects - only exclude ObjC pods
    config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'
    config.build_settings['LD_RUNPATH_SEARCH_PATHS'] = ['$(FRAMEWORK_SEARCH_PATHS)']
    config.build_settings['SWIFT_VERSION'] = '4.0'
22 Answers

โœ”๏ธAccepted Answer

I was also facing the same problem and able to fix by adding swift_version in pre_install block.

pre_install do |installer|
  installer.analysis_result.specifications.each do |s|
    s.swift_version = '4.2' unless s.swift_version

Is there any other solution instead this.

Other Answers:

The problem is even though I manually set all pods back to use Swift 4.0, pods are still not building. Of course also deleted all DerivedData and removed Pods folder and workspace file and do a pod install agian. Anyone has similar problems?

I will create a small project to demo the issue.

This compiles just fine for me, used CocoaPods 1.6.0.beta.1 (did not try 1.5.3)

screen shot 2018-09-20 at 11 21 32 pm

Also your claim that 'Mixpanel-Swift' does not appear to hold. I correctly see the version Swift 4.0 for this pod set.


@newmanw your first piece of code shows the syntax for if in Ruby, so it's trivial to apply to your second piece of code:

pre_install do |installer|
    installer.analysis_result.specifications.each do |s|
        if == '<insert name of your pod here>'
            s.swift_version = '4.2'

More Issues: