Good afternoon,
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.
Regards.
Running pod install --repo-update
and closing and reopening x-code fixed this issue on all of my pods that had this error.
I attempted
pod install --repo-update
and all of these still did not fix the problem.
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.
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.
For me, just cleaning project works using ShiftCommandK & OptionShiftCommandK.
Class re-declaration will be the problem. check duplicate class and build.
For me, the error message said I had too many simulator files open to build Swift. When I quit the simulator and built again, everything worked.
In my case, there was a duplicate entry for a framework in the Input Files of Carthage framework section in Build Phases
Here is the solution: - 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. : )
in my case the problem was due to watchkit extension being set to swift 3 while the main project's target was set to swift 4.2
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'
end
end
end
end
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.
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.
So":
Simply remove the path for file "common crypto" in the build settings and the project will build like a charm! :)
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 have the same issue and my solution is change a little thing in Build Settings
SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OPTIMIZATION_LEVEL = "-O";
ERROR = Command CompileSwiftSources failed with a nonzero exit code
In my case When I found this error, I got cramped with compilation. But when I see some related problem answers. I found a duplication file on my project. Where the same viewController was there as a class file. So yeah when I realized it I changed it name to new one. And yeah things changed!!!
I did the following and it works like charm:
Locations
tabDerived Data
The finder window will open up and show the following folders:
DerivedData
Archives
iOS DeviceSupport
UserData
DocumentationCache
iOS Device Logs
Quit Xcode
DerivedData
folder (it just contains a cache from previous builds)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 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.
Source: Stackoverflow.com