Xcode 10.2, Swift 5, Command compileSwift failed while build the program with Release Scheme

前端 未结 7 1327
我寻月下人不归
我寻月下人不归 2021-01-03 22:38

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 non

相关标签:
7条回答
  • 2021-01-03 23:10

    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
    
    0 讨论(0)
  • 2021-01-03 23:12

    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

    0 讨论(0)
  • 2021-01-03 23:16

    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.

    0 讨论(0)
  • 2021-01-03 23:17

    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.

    0 讨论(0)
  • 2021-01-03 23:24

    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
    0 讨论(0)
  • 2021-01-03 23:27

    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.

    0 讨论(0)
提交回复
热议问题