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

k.s.
  • 2,964
  • 1
  • 25
  • 27
Ran Bi
  • 251
  • 1
  • 2
  • 8
  • can you please share the name of pods which you are using – shivi_shub Mar 26 '19 at 07: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 – Sanad Barjawi Mar 26 '19 at 07:27
  • Here are the pod list: Alamofire, Kingfisher, SwiftyJSON, SnapKit, SwifterSwift, LightBox @shivi_shub – Ran Bi Mar 26 '19 at 07: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 – Ran Bi Mar 26 '19 at 07:40
  • i think one of your pod is not compatible with swift 5 – shivi_shub Mar 26 '19 at 09:01
  • Even if I set Swift Language Version to Swift 4.2, it won't build successfully, I'm thinking this is a bug of Xcode 10.2 – Ran Bi Mar 26 '19 at 09:39
  • In my case, I have an issue, when I try to archive a project with pods, it took infinite and never ended – Diego Carrera Mar 27 '19 at 10:12
  • In my sake it appears to be related to this https://github.com/hyperoslo/Cache/issues/238 which is included because of Lightbox – StackJP Mar 27 '19 at 23:18
  • @ran-bi try to copy past the error text from Xcode next time and don't use the screenshot. – Olcay Ertaş Mar 28 '19 at 09:12

7 Answers7

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

Olcay Ertaş
  • 5,987
  • 8
  • 76
  • 112
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.

Neil Faulkner
  • 526
  • 1
  • 4
  • 22
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
Dimillian
  • 3,616
  • 4
  • 33
  • 53
  • 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. – Ran Bi Mar 26 '19 at 14:20
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
cgontijo
  • 286
  • 2
  • 7
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.

An Chin
  • 463
  • 5
  • 8
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.

Asadullah Ali
  • 1,056
  • 14
  • 31
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.

Ashish Langhe
  • 421
  • 1
  • 5
  • 15