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/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
And > Command /usr/bin/ditto failed with exit code 1
I tried https://stackoverflow.com/questions/26156561/xcode-6-0-1-command-applications-xcode-app-contents-developer-toolchains-xcoded, but it's a different situation.
Solution 1 - Ios
Have you tried to do clean with Clean build folder?
The combination keys is:
ALT + SHIFT + COMMAND + K
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
- Clean Xcode. (cmd+shift+k)
- Quit Xcode completely.
- Open project again.
- Wait for Xcode to indexing files.
- 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:
- click on the directory in project navigator where many files show as red
- Under "Identity and Type" in the File Inspector (on the right side), click Containing directory
- Select the new directories
- 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.
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.
- Open terminal
- Type git clean -n // it will show you list of files which are deleted from project but still are saved somewhere
- 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.
- xcode on screen and click on xcode top menu bar.
- Than go to toolchains option and check on xcode 9.2. thats it.
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 "
- 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
- Clean the build in Xcode cmd+shift+k.
- Update the pods.
- look the where errors showing.
- Add the missing files in Xcode.
- 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 .
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')