How to fix "Bus error 10" after update to Xcode 10.2

Temporary Workaround

For me it was only the Cache framework. Until they have fixed it, you can manually set SWIFT_OPTIMIZATION_LEVEL to -Onone for the configuration you want to use for archiving.

CocoaPods

You could even use your Podfile if you don't want Cococapods to overwrite the settings every time you run pod install

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            if target.name == 'Cache'
                config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
            end
        end
    end
end

Note that this is specifically checking for the Cache framework. If you have problems with other frameworks you might want to change or extend this condition.


While Lukas' answer of disabling optimization on the Cache pod works, I followed Alex's link to the issue in their GitHub repo and found there is an open pull request with a pretty simple code change that fixes it. I unlocked the file and made the change locally.

Here's the PR: https://github.com/hyperoslo/Cache/pull/236

Apply this diff: https://github.com/hyperoslo/Cache/pull/236/commits/560f00a9a9549db161ca70d96eed74fc580b03e3#diff-9e53dc1370d4f7c9cdaaa103d26ff096

Which, to repeat here, is in the file MD5.swift change the safe_add function to be:

func safe_add(_ x: Int32, _ y: Int32) -> Int32 {
  return x &+ y
}

(Disclaimer: I do not claim to know the correctness of the change, but it seems the delay merging the PR is due to figuring out who is currently maintaining the repo.)