20

I'm using Xcode 10.2, Swift 5.

With Debug scheme, no issue happens, but with Release scheme when I build or archive, it shows Command compileSwift failed with a nonzero exit code.

I've tried delete DerivedData / Clean / pod deintegrate & pod install & pod update. None of these works.

enter image description here enter image description here

9
  • can you please share the name of pods which you are using Commented Mar 26, 2019 at 7:25
  • try to remove the messed up pods from the Podfile and perform a pod install. ** if that doesn't work try: ** Clean and build the project. Add again the Pods to the Podfile and perform a pod install. Clean and build the project again using a real device if possible. ** try this if the above two dont work: ** make sure to Set Swift version to your current version then pod deintegrate, pod install, fix this Commented Mar 26, 2019 at 7:27
  • Here are the pod list: Alamofire, Kingfisher, SwiftyJSON, SnapKit, SwifterSwift, LightBox @shivi_shub Commented Mar 26, 2019 at 7:38
  • # pod 'Alamofire' # pod 'Kingfisher' # pod 'SwiftyJSON' # pod 'SnapKit' pod 'DeviceKit' pod 'PKHUD' pod 'FMDB' # pod 'SwifterSwift' pod 'Tabman', '~> 2.2' pod 'FLEX', '~> 2.0' pod 'MJRefresh' pod 'UITextView+Placeholder' pod 'Bugly' # pod 'Lightbox' pod 'FSCalendar' pod 'RxSwift', '~> 4.0' pod 'RxCocoa', '~> 4.0' here are all the pods I'm using Commented Mar 26, 2019 at 7:40
  • i think one of your pod is not compatible with swift 5 Commented Mar 26, 2019 at 9:01

7 Answers 7

8

For my project problem was related to pod Cache which gives error when Optimization Level for Release is set to Optimize for Speed [-O]. I have set Compilation Mode to Whole Module again and set optimization level for the pod in pod file:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    # Cache pod does not accept optimization level '-O', causing Bus 10 error. Use '-Osize' or '-Onone'
    if target.name == 'Cache'
      target.build_configurations.each do |config|
        level = '-Osize'
        config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = level
        puts "Set #{target.name} #{config.name} to Optimization Level #{level}"
      end
    end
  end
end

Refrence: https://github.com/hyperoslo/Cache/issues/233#issuecomment-477749560

Sign up to request clarification or add additional context in comments.

Comments

6

I fixed this issue by going Pods Project then to the building settings and setting Compilation Mode to Incremental for Release. Then clean and archive, should compile fine then.

1 Comment

This is working but building archive is taking too much time.
1

So I had same issue when updating my project to Swift 5. For some reason, Cocoapods (latest version, 1.6.1) set the SWIFT_VERSION of some pods to Swift 5 even if they're released as Swift 4, 4.1, 4.2 pods. So I had to add a post install script that set the correction version of swift like so

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'CryptoSwift' || target.name == 'SwiftyBeaver'
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '4.2'
      end
    end
  end
end

1 Comment

I've set all the target of Pod Project's Swift Language Version to 4.2 manually, as well as my own project, but still it won't work.
1

I had the same issue after upgrading to Xcode 10.2. After following the steps below it worked for me:

  1. Update pods
  2. Clean project folder
  3. Change Pods project's Swift Language Version to Unspecified and (as suggested by @Neil Faulkner) Compilation Mode to Incremental

Comments

1

I had to set "Optimization Level" in "Swift Compiler - Code Generation" to "Release" - "No Optimization [-Onone]" from "Optimize for speed" to make Cache pass Archive.

Same with SwiftyBeaver

It seems a problem related to Xcode 10.2. Also other pod projects seems to be fine with Optimization, like Toucan or XCGLogger.

Comments

1

In my case it just appeared probably because I ran project again while it was building. So what I did was not only clean but also folder clean my project using

SHITF + ALT + COMMAND  + K 

also I deleted derived data and the project was up and running again.

Comments

0

you can follow this steps...

  1. Make sure to change Swift version to your current version.
  2. Update all your pods.
  3. Clean all derived data of Xcode.
  4. Now Restart your Mac.

You are getting all those error's just because of pods..so either you need to update every pod that you are using.

1 Comment

Thanks for answering, but I've tried all these steps, it didn't work for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.