Xcode12.0(12A7209) Error: Compile Swift source files

Only certain Test Scheme are getting errors in Swift source files.

The error output to the log with the Compile process message is as follows. I hope someone can fix this build error🤧

Compile Swift source files (x86_64)
Code Block terminal
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'HogeApiTests' from project 'Hoge')
...
<unknown>:0: error: unable to execute command: Illegal instruction: 4
<unknown>:0: error: compile command failed due to signal 4 (use -v to see invocation)


Compile HomeSpec.swift (x86_64) ※ Most Swift files get this Error
Code Block terminal
CompileSwift normal x86_64 /Users/HogeUser/job/Hoge/HogeApiTests/Entity/HogeSpec.swift (in target 'HogeApiTests' from project 'Hoge')
...
Command CompileSwift failed with a nonzero exit code



Compile Hoge12Spec.swift (x86_64) ※ I get this Error in some Swift files
Code Block terminal
CompileSwift normal x86_64 /Users/HogeUser/job/Hoge/HogeApiTests/Entity/Hoge12Spec.swift (in target 'HogeApiTests' from project 'Hoge')
...
error: Illegal instruction: 4 (in target 'HogeApiTests' from project 'Hoge')






I'm also getting the same error with Xcode 12.1 when running tests with Quick + Nimble. The compiler seems to have trouble type-checking the tests
Did you fix it? Seeing the same error with Xcode 12.5
Did you fix it? Seeing the same error with Xcode 12.5
Did you fix it? Seeing the same error with Xcode 12.5

Also seeing the same in 12.5

Did you fix it? Seeing the same error with Xcode 13

Did you fix it? Seeing the same error with Xcode 13

Follow these steps

#1. Clear de DerivedData folder

  • rm -rf ~/Library/Developer/Xcode/DerivedData

#2. Clean Xcode project

  • cmd + shift + k

#3. Close Xcode project, maybe even reboot the mac (if you like)

Try again. The first step was the crucial step for me, but step 2 and 3 could help as well.

Xcode12.0(12A7209) Error: Compile Swift source files
 
 
Q