Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 10 build fails with 'Command CompileSwift failed with a nonzero exit code

I updated Xcode to version 10 recently and started to receive a strange error when trying to build my project. I'm currently on Swift 4.0 and I did try to upgrade to swift Version 4.2. But when I did I received this same error in many of my frameworks.

Command Compile Swift failed with a nonzero exit code

So far I've deleted the derived folder. Updated all pods, also deleted all pods and reinstalled them using the terminal commands below.

sudo gem install cocoapods-deintegrate cocoapods-clean
pod deintegrate
pod clean
pod install

This didn't work to fix my issue. However, I found something that could work which was adding arm64 architecture in Build Setting -> valid architectures and enabling automatic code But, when I checked it was already there and code signing was enabled already.

Additionally, I do have a few other build errors that have to do with frameworks.

SwiftMessages

Value of type 'SwiftMessages.Config' has no member 'presentationContext'

WhatsNewKit

Missing argument for parameter 'backgroundColor' in call`

I opened issues with the developers of each of these frameworks to seek help with these issues.

Issue On SwiftMessage GitHub Issue On WhatsNewKit GitHub

When I click presentationContext it brings me to the struct within the SwiftMessages Framework. Usually, when I've had the "has no member" warning I cannot click to see the original place where it exists.

I assume this has something to do with cocoa pods, but haven't been able to find a solution yet. What can I do to correct this issue? If anyone could help would be deeply appreciated been stuck on this for a day now.

Update: The two frameworks latest builds were for swift 4.2. When I changed the version of each framework to one that was built in swift 4.0 I got the project to build.

like image 412
Spencer Shelton Avatar asked Sep 20 '18 00:09

Spencer Shelton


People also ask

What is nonzero exit code?

A non-zero exit status indicates failure. This seemingly counter-intuitive scheme is used so there is one well-defined way to indicate success and a variety of ways to indicate various failure modes. When a command terminates on a fatal signal whose number is N , Bash uses the value 128+ N as the exit status.


14 Answers

Make sure that, your project Swift Language Version is in the proper version. SwiftMessages 6.0.0 works with Swift 4.2. Xcode->Project->Target->Build Settings->Swift Language Version

like image 53
Karim Karimov Avatar answered Oct 03 '22 14:10

Karim Karimov


I solved this way:

  1. Comment all pods in your .pod file
  2. From your terminal, run the command pod install --no-repo-update
  3. Open Xcode perform a clean and rebuild the project
  4. Now open your .pod file and uncomment the first library
  5. From your terminal, run the command pod install

Repeat steps 2 - 3 - 4 -5 for each uncomment library in your .pod file

I hope it can be of your help.

like image 41
Diego Avatar answered Oct 03 '22 14:10

Diego


Make sure that, Your project build settings Optimization Level is in No Optimization[-Onone].

enter image description here

like image 24
Ramkumar Paulraj Avatar answered Oct 03 '22 15:10

Ramkumar Paulraj


for pod SwiftMessages if your app is not swift 4.2 you need to user the version 5.01 pod 'SwiftMessages', '~> 5.0.1'

and it will work like a charm

like image 23
Jeremy Vandermeersch Avatar answered Oct 03 '22 15:10

Jeremy Vandermeersch


Set Swift version to 4.2 then pod deintegrate, pod install, fix this problem for me. Thanks @alejandro-iván

like image 24
yybot Avatar answered Oct 03 '22 15:10

yybot


Good Morning! Do a clean. using"commond + shift + k Close Xcode. Navigate to project directory where the Podfile exist. Do pod update/pod install Open x.xcworkspace

like image 39
Anubhav Singh Avatar answered Oct 03 '22 13:10

Anubhav Singh


enter image description here

This error happened to me when I used same class name in two different groups. Then I renamed one of the classes and the problem was solved

like image 41
Abdul Saleem Avatar answered Oct 03 '22 15:10

Abdul Saleem


All of the answers were helpful to me. In my case, I only install frameworks manually but this kind of problem also happens. I tried all of the answers and was still getting this issue during the build. Curiously, while coding, I could cmd-click and resolve all of the "missing" components. I also cleaned and deleted derived data, restarted Xcode, etc.

I eventually got it working by inducing these additional steps:

On each of the framework project/targets (including my own):

  • Verify consistent Swift version (4.2 in my case)
  • Set Build for Active Architecture Only to No
  • Set Valid Architecture to arm64, armv7 (to match with base project)
  • Set Optimization Level to None (for Debug)
  • Set Compilation Mode to Whole
like image 24
Tommie C. Avatar answered Oct 03 '22 13:10

Tommie C.


I had several frameworks (homegrown) plus my app. Somehow they ended up being out of sync as far as the Swift version. Make sure that all frameworks are the same version. In my case, they all needed to be set to Swift 4.2. If you haven't done the migration to 4.2 then remember that Xcode helps with this: Edit -> Convert -> To Current Swift Syntax.

like image 36
Phantom59 Avatar answered Oct 03 '22 15:10

Phantom59


only for re-install pod using that command pod install
see below attachment

enter image description here

like image 21
prit malani Avatar answered Oct 03 '22 15:10

prit malani


In my case I connect an actual iphone not simulator and run the app once on it, It solved the problem. But connect iphone firstly, then choose it from this menu, then press run button. The problem will solve too.

enter image description here

like image 21
Gerges Eid Avatar answered Oct 03 '22 15:10

Gerges Eid


I stumbled upon this problem when upgrading to Xcode 10.2 and Swift 5. After trying everything I found this in the release notes:

The Swift compiler may crash during a build when the Thread Sanitizer is enabled. (48719789)

And sure enough, efter turning off Thread Sanitizer my project could be compiled without errors again.

So if you get this error and have Thread Sanitizer enabled - turn it off!

like image 39
rodskagg Avatar answered Oct 03 '22 14:10

rodskagg


Same issue happened to me in Xcode 10.2, it was a Xcode bug..! So, I opened in older Xcode version(9.4), and it worked fine. Then I updated to the Xcode 10.2.1 after it's release -> Clean and build your project, now my problem solved.

like image 1
Fuhad saneen Avatar answered Oct 03 '22 15:10

Fuhad saneen


I'm having the same problem, my Xcode version is 10.2.1 (10E1001), Cocoapods version is 1.7.0.beta.2.

I returned to Cocoapods 1.6.1 and the problem was solved. The specific steps are:

  1. pod deintegrate to cancel the integration.
  2. Uninstall all Cocoapods.

    for i in $( gem list --local --no-version | grep cocoapods );
    do
        gem uninstall $i;
    done
    
  3. Install the stable version of Cocoapods. For now it's 1.6.1.

    gem install cocoapods
    
  4. Clean Project and empty DerivedData⁩

  5. pod install
  6. Recompile the project
like image 1
Vincent Sit Avatar answered Oct 03 '22 15:10

Vincent Sit