Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

After updating to the latest version of Xcode at the moment (version 10.0) the project is unable to build because it found some errors regarding some "Command CompileSwift failed with a nonzero exit code" error.

How do I solve this errors? They appear in most of the Pods (I use CocoaPods) I use inside my project.

I have tried updating the pod version and the pods to the latest version available, but the problem is still there.

I have searched a lot through the web and there is very little information regarding this issue.

pod install --repo-update , then in your xCode clean build folder and delete derived data, try build again after that. inokey Sep 18, 2018 at 13:15 Another possible solution (that worked for me) is found here: stackoverflow.com/a/52481653/96153 yo.ian.g Oct 5, 2018 at 3:06 Yup, this worked for me too Xcode 10.2.1, iOS 2.3.1, iPhone XS Max. Thank God it wasn't going to be looking for a needle in a haystack. I didn't change that much between last compile and where I was getting that error. clearlight Jun 15, 2019 at 6:50 This answer is the equivalent of IT, telling people to try turning it off and on again. Which of course it solved for me. C. Skjerdal Aug 26, 2019 at 21:56 I updated my xcode to 10.3 and faced similar issues. I tried all the tricks nothing helped but as indicated in here in bold, "Restarting the mac did the trick", it worked for me. Yoku Jul 23, 2019 at 11:29 Hate to say that but restarting my mac did solve the issue for me. BTW I got this error after upgrading Xcode to 10.3. luin Jul 24, 2019 at 6:39 The thing with restarting the Mac might look funny, but it's a valid point! In my case I modified the .bash_profile , then quickly in the terminal loaded it: source .bash_profile and proceeded to work. So after few days when I returned back, I had again issues because .bash_profile was not loaded... Then restarting does indeed help :) Andy Res Jul 21, 2020 at 13:48
  • Search in the whole project the word CommonCrypto.
  • If you have a Pod containing that header import, remove this Pod from the Podfile and perform a pod install.
  • Clean and build the project.
  • Add again the Pod to the Podfile and perform a pod install.
  • Clean and build the project again using a real device if possible.
  • And If you don't have that Pod, maybe you can try by making the same steps with some old Pod that you may encounter in your project.

    Added information: also If you have some code error inside a Pod, first you need to solve that code problem and then try to compile again the project.

    I'm going to copy the changes made in my project.pbxproj. I know it's not very helpful but it's the only thing that have changed in the git difference commit:

    Removed: BDC9821B1E9BD1B600ADE0EF /* (null) in Sources */ = {isa = PBXBuildFile; };
    Added:   BDC9821B1E9BD1B600ADE0EF /* BuildFile in Sources */ = {isa = PBXBuildFile; };
    

    I hope this can help,

    Regards.

    This helped me fix the problem. When I turned Whole Module mode on it started reporting actual errors to me rather than a generic high level failure. Once all fixed you can then change it back to Incremental, if that's what you'd like. – CMash Oct 30, 2018 at 8:53 Any hints where to find this setting? i looked under build settings for my targets and build settings for the project and cant find it (by searching for it) maybe because im on an objective-c project thats quite old? – Fonix Nov 20, 2018 at 7:39 It's under Swift Compiler -> Code Generation. Alternatively it may sometimes be listed under User Defined -> SWIFT_COMPILATION_MODE – Werner Altewischer Nov 20, 2018 at 8:31 Thanks for the tip and it fixed my problem. My case is to migration project to Xcode 10.2 and Swift 5. I wrote detail explanation about it in my blog: davidchuprogramming.blogspot.com/2019/03/… – David.Chu.ca Mar 29, 2019 at 18:21

    This is a known issue with Swift 4.2 and Xcode 10. I found an article here that fixed it for me: https://github.com/Yummypets/YPImagePicker/issues/236

    In short, go to your projects build settings, and add a user defined setting named SWIFT_ENABLE_BATCH_MODE and set its value to NO.

    Previously, I tried each of the following methods suggested elsewhere (rebuild, exit Xcode, clean and rebuild, purge Derived Data files). None of them worked.

    Once I added the user define build setting per the article, Swift then told me the true error. In my case, it was a missing }, but it could be any number of problems.

    However, I get this error message instead: Command PrecompileSwiftBridgingHeader failed with a nonzero exit code – Van Du Tran Nov 26, 2018 at 17:02

    My problem was I had due to the non-existence of a native Swift CommonCrypto, used a bridging header and a target that with some magic included it in the build. Since CommonCrypto is now native, I solved the problem by removing the target and the #import and instead added an import CommonCrypto where I used it.

    Yes! I had this too (No cocoapods or anything like that, just CommonCrypto) Thanks for saving my day – Orion Edwards Sep 25, 2018 at 11:47 @OmidAriyan Hello, guys this issue had stopped me from working for the past two weeks :s, I tried almost all solutions found on this website but its simply not working. For your answer I didn't get the point actually. Would you please clarify your answer for me in details? What is the problem and what should I do in steps please :(:( – mojtaba al moussawi Nov 20, 2018 at 16:21 @mojtabaalmoussawi I had basically followed stackoverflow.com/a/42852743/1038245 in order to use CommonCrypto in my project before Xcode 10 was released. I just tried to undo that to fix the error that is the topic of this question. – Omid Ariyan Nov 21, 2018 at 16:12
  • Open Xcode Preferences (Command,)
  • Go to the Locations tab
  • Click on the small gray arrow which shows URL path for Derived Data
  • The finder window will open up and show the following folders:

  • DerivedData
  • Archives
  • iOS DeviceSupport
  • UserData
  • DocumentationCache
  • iOS Device Logs
  • Quit Xcode

  • Delete the DerivedData folder (it just contains a cache from previous builds)
  • Restart Xcode
  • - Go to build settings - Search SWIFT_COMPILATION_MODE - If this is "Whole Module" for Release configuration then change it to "Incremental". - Archive now.

    When you change the setting to "Incremental" the process succeeds.

    Mine was a name spacing issue. I had two files with the same name. Just renamed them and it resolved.

    Always gotta check the 'stupid me' box first before looking elsewhere. : )

    Let me share my experience for this issue fix.

    Open target -> Build phases -> Copy Bundle Resources and remove info.plist.

    Note: If you're using any extensions, remove the info.plist of that extension from the Targets.

    Hope it helps.

    This right here! This was bugging me for so long! When you are adding frameworks/extensions to your libraries, make sure that both the extension and the library are looking at the same Swift Language Version! Thanks @Itay – Zez3 Aug 21, 2019 at 12:59

    It seems like this is a pretty vague error, so I will share what I did to fix it when I ran into this:

    Using Xcode 10.1 and Swift 4.2 I tried pretty much all the suggestions here but none of them worked for me, then I realized a dependency I was using was not compatible with Swift 4.2 and that was causing me to get this error on other pods. So to fix it I just had to force that pod to use Swift 4.0 by putting this at the end of my Podfile:

    post_install do |installer|
        installer.pods_project.targets.each do |target|
            if ['TKRadarChart'].include? target.name
                target.build_configurations.each do |config|
                    config.build_settings['SWIFT_VERSION'] = '4.0'
    

    I searched the whole web but I couldn't find any solution for this problem. I managed to REMOVE the "Common Crypto" path in the section: IMPORT Paths in Build settings. The problem seems to be that "common crypto" now exists in the foundation in the ios 12 sdk.

    Simply remove the path for file "common crypto" in the build settings and the project will build like a charm! :)

    Yes. Go to Build settings, select "All" Tab instead of "Basics" or "Customized". Now search for : "Swift Compiler - Search Paths" Here if there exists a path for common crypto, remove it. – sajede Nouri Oct 5, 2018 at 5:54

    Just adding to this question. My issue didn't have anything to do with CommonCrypto. It created a new Single App application and tested to run. Compiler was complaining about using Swift 4.2

    Changing the Swift language to version 4.0 in Build settings fixed the issue. Not sure if this is a bug.

    I got this randomly since Xcode 10. I think it occurs when I change something in the code while building starts. The next build works every time.

    I also encountered the same issue and I did what @cdeerinck suggested and got to the following link which suggested adding a user-defined variable to the Build Settings to disable batch mode i.e. add a new user defined variable named SWIFT_ENABLE_BATCH_MODE and set it to NO, I was able to get more insights into the issue and I got to know that the error was in a framework using CommonCrypto which was added to it(by me) but since Xcode 10 it is exposed natively as part of Swift (for Apple platforms only), and adding it (or its existence from the previous version) was causing a name collision and hence it was throwing the error. To know more refer to the this link which explains the issue in more detail.

    I have the same issue and my solution is change a little thing in Build Settings

    SWIFT_COMPILATION_MODE = singlefile;
    SWIFT_OPTIMIZATION_LEVEL = "-O";