43
votes

When I compile my code on Xcode Version 8.0 beta 4 (8S188o) I get this single error bringing the compilation to failure:

Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

I tried to clean the project and wipe the derived folder but that did not change things. What is it and how may I know more about it?

When I try to compile on the terminal the error being reported is:

Invalid bitcast\n %.asUnsubstituted = bitcast %swift.error* %13 to i2, !dbg !438\nLLVM ERROR: Broken function found, compilation aborted!\n

25
Ys, thanks, I did. Yet there are a number of assorted answers. I tried setting the optimisation to none in release, but that changed nothing. - Fabrizio Bartolomucci
And most of them refer to issues now correctly detected by the compiler. - Fabrizio Bartolomucci
The issue seems due to the not found files. I tried to compile a project without this issue and it did it jut fine. - Fabrizio Bartolomucci
By doing git add * and then committing the warning disappeared but no so the error. - Fabrizio Bartolomucci

25 Answers

53
votes

Happened to me, when I had two classes with the same name in my project. After deleting the redundant one, error disappeared.

19
votes

If you look above the error, Xcode will tell you which ViewController is added/declared twice, navigate to it and remove the reference. Build and you're good to go.

16
votes

I am going to tell you my silly mistake, the error is showing the issue and It took 3 hours to me to understand. look into below error

enter image description here

look into above 2 lines of error, the problem is shown, Obviously, In my case Xcode is complaining that Location.swift and Customer.swift file is missing, look into my project hierarchy, the same issue can understand.

It's my advice to everyone that first understand the error and then look into issues. I removed my desktop files, which were referenced in the project, and therefore compile error occurred.

enter image description here

15
votes

Clean your project that fixed my project Product/clean

13
votes

I got this error for core data models that i've created manually.And it got resolved by changing particular entity's 'Codegen' attribute to 'Manual/None' under Data Model Inspector.

4
votes

If you change any file folder location or change any Objective-C Bridging file path. Then it's happened some time.

  1. Update your Bridging path.
  2. Clean your project alt + Shift + Command + K
  3. Quit Xcode completely Command + Q
  4. Open project again and wait for Xcode to index files.

enter image description here

3
votes

I got this error when I was trying to run an xcode project. A swift file wasn't being found and complied correctly, even though clearly in the xcode project file you can see the swift file and when you click on it in finder the file comes up as a separate xcode swift file. I solved this by:

  • Deleting the problematic swift file
  • Creating a new swift file with the same name
  • Xcode prompts that the file is already created, press replace
  • copy/replace the code/etc. in the file
  • Clean the project (for good measure)
  • Run the project
2
votes

The problem went away by itself for mysterious reasons. Instead of the whimsical linking error I got a new bunch of errors due to Swift 3 fling which the app compiles and run fine.

2
votes

The solution that worked for me is I had to delete the .xcdatamodeld file in my project and create a new one. This solved it.

2
votes

I got this error and resolved by changing Xcode command line tools,

Goto Xcode -> Preferences -> Choose Locations tab

Choose required Command Line Tools from drop down, run the project error has been fixed.

1
votes

In my case the error triggered when Xcode could not find a file/folder from the external Framework and dependency. In such a case just pod update / pod install do the job.

1
votes

Try removing inactive file(deleted file) from Build phases...

1
votes

Based on @Mohammed Rizwan N answer

If error not gone, do the clean project and close Xcode. Then click right button on .xcodeproj/.xcworkspace file and choose appropriate Xcode version.

In my case, I tried to run a project in Xcode9/Swift4, while the project was written on Xcode8/Swift3

1
votes

1.Go to build settings and check the path of the info.plist file and bridging header file.

2.If not sure they are correct , from the left side drag and drop the files into respective fields .This creates the path automatically .

  1. Clean the project and build again .

Build settings screen shot

0
votes

I created 3 new groups and put my MainVC under one of those groups. After I deleted one of the new groups I created, the error went away after I cleaned my project.

0
votes

Please update your entire log which suggests the error, mine is telling me I have duplicated classes in file

0
votes

Try closing Xcode, cleaning the project and building again.

At first, cleaning wasn't enough. I had to actually close it and try again.

0
votes

I faced this issue when I resolved git conflict for the project file, which was for adding and removing some files.

What I found out is Xcode creates the folder named folder named "Recovered References", just search this from bottom left search option from Xcode and delete it. After you delete it you will only get an error for missing files. Resolve that by adding files again by right-clicking and selecting add files option. Once you are done with it project compiles with no error.

0
votes

Happened to me when I found two swift files with the same name within the project, even if the classes have different names.

0
votes

In my case error came when I moved my bridging-Header.h file from one folder to another. and when I checked in Build Settings -> Objective-C Bridging Header it was showing old path. Then I moved that file back to previous folder.

0
votes

My problem was that my machine was running out of available space. Restarting it cleaned up ~8GB of temporary files, but I guess you can also delete something instead.

0
votes

This is mainly because xcode is not getting the exact path of any file or duplication of file name under linking area.

In my case I have added bridge header file under Resources file and added the path in BuildSettings->Objective-C bridge header-> bridgehearfilename.h

You should specify the exact path of that file in this section.

eg: BuildSettings->Objective-C bridge header-> Projectfolder/Resources/bridgehearfilename.h

Correct your file paths in the build settings then Clean and build the project.

0
votes

For me it was ,

Product > alt + Clean Build Folder

OR

alt + Shift + Command + K

0
votes

Do these 3 steps:

  1. Clean Project: Shift+Command+K

  2. Make sure low disk space shouldn't be on your mac

  3. Focus on the upper lines of this error...Try reading them again...Paste those files that are missing or having some light icon in xcode project navigator and delete those files with light icon.

Hope you will fix the error.

0
votes

I tried to run a project in Xcode12/Swift4, while the project was written on Xcode8/Swift3 so I install Xcode version 11.7 and run this work for me.