8

I've downloaded the latest Xcode 11.2.1. When I build I'm getting this error.

<unknown>:0: error: using bridging headers with module interfaces is unsupported Command CompileSwiftSources failed with a nonzero exit code

How can I resolve this?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tumenbayar SaS
  • 81
  • 1
  • 1
  • 2
  • Does this answer your question? [Command CompileSwiftSources failed with a nonzero exit code Xcode 10](https://stackoverflow.com/a/52481653/4414956) and this: https://stackoverflow.com/questions/52415877/xcode-10-build-fails-with-command-compileswift-failed-with-a-nonzero-exit-code – nuaky Dec 05 '19 at 10:19
  • Do you use any obj-c code in the project? Is this error occurred only in old or newly created project also replicated the same error? – iSrinivasan27 Dec 05 '19 at 10:28
  • Note: Duplicate of [this Deleted question](https://stackoverflow.com/questions/58411422/how-to-fix-using-bridging-headers-with-module-interfaces-is-unsupported-upgrade) (with no answers), and considering the time of [the same question on the official forums](https://forums.developer.apple.com/thread/123422), it was also happening with Xcode 11.0. – Cœur Dec 05 '19 at 12:58
  • Continuation of previous comment: both linked questions show that they were using CocoaPods, so I suspect that there are simply using outdated versions of CocoaPods and/or Xcodeproj dependency. For Xcode 11, you need to use **CocoaPods 1.8.4** and nothing older. – Cœur Dec 05 '19 at 13:06

1 Answers1

14

I solved this build error by setting Build Options -> Build Libraries for Distribution in the targets Build Settings to No.

I stumbled upon this config change that worked for me so I don't have any evidence/research to back up why it works. And I have only tried this for debug builds, will update my answer if anything changes. Your milage may vary.

My project specs below:

Xcode 11.1 (11A1027)

Brownfield React Native iOS app

Dharman
  • 30,962
  • 25
  • 85
  • 135
Tony Xu
  • 194
  • 2
  • 9
  • 24
    Umm... I have just enabled this option because of error: `module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler` So you either have one error or another? – Simon Moshenko Mar 30 '20 at 14:53
  • @SimonMoshenko I've come into similar situation, have you ever find solution to this issue? – zionpi Apr 28 '20 at 02:42
  • true that, I have also encountered same issue similar to @SimonMoshenko do we have any update here? – Nikhil Bhawsar May 02 '20 at 22:49
  • I don't think I found a solution. I think I had to ditch an import statement to my framework, or whatever was causing the issue. – Simon Moshenko May 03 '20 at 09:21
  • Regarding @SimonMoshenko's error, please see [this](https://stackoverflow.com/a/58656323/6597956) answer. Which is way more thorough and might be helpful for you guys. Please note that my original answer is purely anecdotal. In my situation, one of our 3rd-party dependencies required a specific Xcode version (11.1). Which is also the Xcode version that happens to work for all of our other dependencies. – Tony Xu May 03 '20 at 23:22
  • 14
    Setting `Build Libraries for Distribution` to `NO` is not a proper solution because many might require to distribute by XCFramework which forces it to be `YES`. – Sazzad Hissain Khan Oct 05 '20 at 21:19
  • @SimonMoshenko Do you remember how exactly were you able to solve this issue ? I am having this exact issue but only in Release Target and not in Debug Target. – dev_ios999 Jun 28 '21 at 13:20
  • @dev_ios999, I solved this issue using the exact steps listed in the OP. Maybe double check that your Release Target has the suggested Build Settings? It's also worth seeing if upgrading your XCode to the latest version might help? – Tony Xu Jun 29 '21 at 14:46
  • it worked for me. Thanks – Shahid Bangash Jul 01 '23 at 19:18