ERROR "swiftc failed with exit code 1" when converting to latest syntax

IosObjective CSwiftXcode

Ios Problem Overview

I was trying to convert syntax of old Swift project to new one as per few suggestion on Stack Overflow I tried converting it through Edit > Convert > To latest Syntax that did not work properly instead I started getting new errors shown as below > Command/Applications/ failed with exit code 1

And > Command /usr/bin/ditto failed with exit code 1

enter image description here

I tried, but it's a different situation.

Ios Solutions

Solution 1 - Ios

Have you tried to do clean with Clean build folder?

The combination keys is:


Solution 2 - Ios

Try delete Derived Data folder and Build it.

Go to Xcode -> Preferences -> Locations for get the derived data path

Solution 3 - Ios

  1. Clean Xcode. (cmd+shift+k)
  2. Quit Xcode completely.
  3. Open project again.
  4. Wait for Xcode to indexing files.
  5. Now run your project.

Solution 4 - Ios

Just had the same issue. For me it was because I had renamed some of the project directories. I had a ton of red files in my project navigator. To solve, follow these steps:

  1. click on the directory in project navigator where many files show as red
  2. Under "Identity and Type" in the File Inspector (on the right side), click Containing directory
  3. Select the new directories
  4. Rebuild - command shift K, command B

Solution 5 - Ios

As far as I know there can be multiple reasons why a compiler fails. Although cmd+alt+shift+k will help most of the time. If this fails, then click on the error message and try to debug it.

For example in the image below, if you read the message, we get to know that, there has been a name duplication. Fixing the name duplication will fix the issue.

enter image description here

Solution 6 - Ios

Just remove inactive file(deleted file) from Build phases


Clean Xcode. (cmd+shift+k)

Solution 7 - Ios

delete Derived Data folder and Build it.

Go to Xcode -> Preferences -> Locations for get the derived data path or cmd+Alt+shift+k


Just remove inactive file(deleted file) from Build phases

Solution 8 - Ios

Cleaning the project wasn't working for me, this is because I didn't pay attention to the message right above (Xcode highlights only the final command).

In my case it was

<unknown>:0: error: filename "FileDuplicated.swift" used twice: '/../filepath/FileDuplicated.swift' and '/../filepath/FileDuplicated.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /../bin/swiftc failed with exit code 1

I had to change the name of one of the two files and it was solved.

Hope this can help someone, cheers

Solution 9 - Ios

In my case it was due to the few swift files which has been showed grayed out in the Build Phases section. After removing those files it was successful.

Solution 10 - Ios

In my case I deleted few files from project and when try to commit the code, the files was showing there . To solve this issue.

  1. Open terminal
  2. Type git clean -n // it will show you list of files which are deleted from project but still are saved somewhere
  3. Type git clean -f // All unwanted files will be removed

Solution 11 - Ios

In my case swift development snapshot was selected instead of xcode 9.2. here are the steps and image.

  1. xcode on screen and click on xcode top menu bar.
  2. Than go to toolchains option and check on xcode 9.2. thats it. enter image description here

Note: If no toolchain found in your xcode than download from Here and install it. (after installation restart xcode). Happy Coding!!!

Solution 12 - Ios

In my case, it was "Other swift flags". I had declared a flag there but not -D, so this was not getting recognized and resulted in the same error

Solution 13 - Ios

Ok, my turn now. In my case I had an existing project. I copied in a few files from another project. One of the files I brought in was SettingsViewController.swift and there was already a file by the same name I was not aware of. The files were in different directories of the project so no duplicate message was shown. The compile/link messages offered no clue to this. I figured out the issue by adding one file at a time to the project (there were 12 total) and the building each time until I found the offending file. I renamed the new file and project builds now.

Solution 14 - Ios

In my case it was a compiler flag change that didn't work well. It took a few compiles before it actually started failing though! Xcode caches what it compiles.

Solution 15 - Ios

I just had this issue. It's due to path references. Have you been moving files around and/or copying folders? Check if .xcodeproj is inside or outside of the main project folder. Also, make sure that the project's file and directory structure are intact.

/yourFolderProjectName/ <-- contains your .xcodeproj file AND folder with Xcode project name

/yourProjectFolder <-- here are .swift, info.plist, assets folder, etc.


Solution 16 - Ios

Another thing to check:

In my case I had deleted a row in the "Other Swift Flags" section in the Build Settings screen under the Release setting.

That row had been a value for a compiler flag key/value pair. So the key was there but not the value.

Once I deleted the key as well, then the build worked again.

Solution 17 - Ios

I faced this issue while using the Swift auto-generated header file in my project (named as 'TargetName'-swift.h) to use Swift classes in Objective-C.

There was a typo in the file where I had imported this swift header. Correcting the typo helped me resolve the issue.

Solution 18 - Ios

This issue is happening because of pods

So Follow the below steps to resolve this issue

  • Remove all the pods and re-install again. Remove all the pods using below this command (rm -rf "pwd/Pods/")
  • Quit the Xcode and open it again and build the app with device (generic iOS device).
  • Now check this issue will be resolved.

Solution 19 - Ios

  1. Clean the build in Xcode cmd+shift+k.
  2. Update the pods.
  3. look the where errors showing.
  4. Add the missing files in Xcode.
  5. After Run the Code. Working fine.

Solution 20 - Ios

I had this error when Xcode found two .swift files with same name. Rename one of them and build again.

Solution 21 - Ios

Wait for completing the indexing and run the project again. You must get an error then check it which may be Objective-c bridging file not found error. This error comes if you are using any Objective-C library or code directly in the project and your project unable to find the bridging file in the system. This issue basically caused by, if project is unable to find any file in the system which is using in the project (path issue).

Solution 22 - Ios

Try below if none of the above working for you.

My project location was desktop/my_project_folder

I tried all above then i made simple change.

I create one more folder on desktop past my project .

then... enter image description here

Cause of problem in my case:

This problem occurred when i change my project name in xcode & project folder name from desktop.

Solution 23 - Ios

I was working on a private pod and was also pointing to it locally. I had made some file name changes.

Hence I was getting this error.

All I had to do was to run pod install so it would reflect the file name changes. After that it compiled.

Solution 24 - Ios

In my case I copied a core data entity and only renamed the entity but not the class. So go to your xcdatamodel and select the enitity > rename also the class name

Solution 25 - Ios

Had the same issue but with duplicate file references. Deleting Derived Data and cleaning had no success. But I got it fixed by doing this:

Navigate to your project.pbxproj -> open with your text editor of choice(I use atom).

Command+F and find the duplicate file sources and then delete them.

Build/Run and should be fixed.

Solution 26 - Ios

For me, it was the keychainAccess problem as described in this answer (my error messages were completely opaque, all I had to go by was 'failed with exit code 1')


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionctpanchalView Question on Stackoverflow
Solution 1 - IosDavidView Answer on Stackoverflow
Solution 2 - IosManuelView Answer on Stackoverflow
Solution 3 - IosMRizwan33View Answer on Stackoverflow
Solution 4 - IosAlaa AwadView Answer on Stackoverflow
Solution 5 - IosSanket RayView Answer on Stackoverflow
Solution 6 - IosRabieView Answer on Stackoverflow
Solution 7 - IosGowtham SooryarajView Answer on Stackoverflow
Solution 8 - IosivorotoView Answer on Stackoverflow
Solution 9 - IosVishnuvardhanView Answer on Stackoverflow
Solution 10 - IosgargView Answer on Stackoverflow
Solution 11 - IosMRizwan33View Answer on Stackoverflow
Solution 12 - IosmohitView Answer on Stackoverflow
Solution 13 - IosxdeleonView Answer on Stackoverflow
Solution 14 - IosLucas van DongenView Answer on Stackoverflow
Solution 15 - IosKevin MorrisView Answer on Stackoverflow
Solution 16 - IosChris GarrettView Answer on Stackoverflow
Solution 17 - IosGurunath SripadView Answer on Stackoverflow
Solution 18 - IosBalajiView Answer on Stackoverflow
Solution 19 - IosPraveen ReddyView Answer on Stackoverflow
Solution 20 - IosNupur SharmaView Answer on Stackoverflow
Solution 21 - IosAkhiView Answer on Stackoverflow
Solution 22 - IosPeter WalterView Answer on Stackoverflow
Solution 23 - IosmfaaniView Answer on Stackoverflow
Solution 24 - IosJanine KroserView Answer on Stackoverflow
Solution 25 - IosJonathan KoppView Answer on Stackoverflow
Solution 26 - Iosgreen_knightView Answer on Stackoverflow