43

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

Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75

25 Answers25

53

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

Adam Bardon
  • 3,829
  • 7
  • 38
  • 73
19

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Giggs
  • 851
  • 10
  • 16
16

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

Naveed Ahmad
  • 6,627
  • 2
  • 58
  • 83
15

Clean your project that fixed my project Product/clean

Jeylani Osman
  • 199
  • 3
  • 13
13

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.

Shyam
  • 417
  • 4
  • 16
4

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
Md Imran Choudhury
  • 9,343
  • 4
  • 62
  • 60
3

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
itsmcgh
  • 783
  • 1
  • 9
  • 12
2

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.

Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
  • I still have stuck in this problem and make clean + Close Project + and try manual and generate . Still the same problem in Archive . My Xcode 8.2.1 and using Swift 3.0 , Could please share the answer for this problem – wod Feb 01 '17 at 21:31
2

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.

PlateReverb
  • 654
  • 1
  • 7
  • 21
2

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

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.

Oskar
  • 2,522
  • 32
  • 37
1

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

Cwalker815
  • 186
  • 2
1

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

Roman Romanenko
  • 736
  • 9
  • 24
1

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

Sateesh Pasala
  • 772
  • 8
  • 15
0

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

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

Mogician Ha
  • 85
  • 1
  • 2
  • 10
0

For me it was ,

Product > alt + Clean Build Folder

OR

alt + Shift + Command + K

Cœur
  • 37,241
  • 25
  • 195
  • 267
iUser
  • 1,075
  • 3
  • 20
  • 49
0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Zeesha
  • 991
  • 9
  • 14
0

Try closing Xcode, cleaning the project and building again.

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

dustinrwh
  • 888
  • 1
  • 14
  • 16
0

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.

Aditya Deshmane
  • 4,676
  • 2
  • 29
  • 35
0

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

Hatim
  • 1,516
  • 1
  • 18
  • 30
0

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.

Khushboo Dhote
  • 198
  • 3
  • 13
0

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.

budiDino
  • 13,044
  • 8
  • 95
  • 91
0

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.

Clean Coder
  • 496
  • 5
  • 12
0

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.

Muhammad Ahmad
  • 388
  • 4
  • 9