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

IosIos8xcode6.0.1

Ios Problem Overview


I am getting this error on archive: >Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

How to solve it?

Please see the screenshot.

error

Ios Solutions


Solution 1 - Ios

This problem occurs when the Swift optimization level is not set to None for Release. Set the value to None and the issue goes away.

  1. Open up your project and click on the projects root directory.
  2. Click the build settings tab.
  3. Search for Swift Compiler - Code Generation and under Optimization Level make sure Release is set to None.

EDIT

After upgrading to Xcode 6.1 these instructions caused other issues when archiving (building for debug/device worked fine). Setting the optimization to Fastest allowed me to archive again. There are apparent issues with Swift compiling still (archiving specifically).

https://stackoverflow.com/questions/26508911/cant-archive-working-6-0-1-swift-project-in-xcode-6-1-segmentation-fault-11/26509115#26509115

EDIT I was not able to fund the Build Settings tab, until I read this answer.

how to find the build settings tab

Solution 2 - Ios

This occurred for me when I had two of the exact same files, and also when I was missing I file I didn't know I had deleted. I clicked on the error message, and just above the error, it shows you what file you have more than 1 of or are missing.

Solution 3 - Ios

You can click the Product in the navigation and choose the "Clean" button; it will clean all compile error in your project. Then, you can debug for the latest error.

Solution 4 - Ios

Deleted files reference keep in Build Phase and that's why it gives this error. Remove reference from there as well.

Project> Target > Build Phase

Under this section you will find your deleted files in red colour. Remove these files error will resolve.

Solution 5 - Ios

I am not sure if it has one solution. I recommend you to check the differences between your last git commit, and comment on/off the changes.

In my case, my code was

let anArray = ResultDict["ResultSet"] as [[NSDictionary : AnyObject]]
for aDict : NSDictionary in anArray {
    let anObject = ObjectType(ObjectDict: aDict)
    objectList.addObject(aDict)
}

no warning on the line, i got the same exit 1 compile error then i changed it to the below it has compiled.

let anArray = ResultDict["ResultSet"] as [[NSDictionary : AnyObject]]
    for aDict in anArray {
        let anObject = ObjectType(ObjectDict: aDict)
        objectList.addObject(aDict)
    }

Solution 6 - Ios

I don't know if this is really an answer, but...

I had the same issue. App worked when building/running, but archiving failed with "...swiftc failed with exit code 1", with no other helpful message at all. Luckily, when I tried to build my app with Nomad's ipa build, I got:

The following build commands failed:
	CompileSwift normal arm64 /path/to/erroneous/TableViewController.swift

So I started commenting out sections of that file and tracked the problem down to a tuple assignment.

// MARK: - Table Data

private var tableData: [(sectionName: String, item:ListItem)] = []

private func refreshTableData() {

	// let labor = ("Labor", laborListItem)                 // DOESN'T ARCHIVE
    let labor = (sectionName: "Labor", item: laborListItem) // ARCHIVES

    tableData = [labor]
    
    tableView.reloadData()
}

So apparently the compiler wanted the elements in thast tuple named (as defined by the type of tableData).. but only for archiving? The Dumb thing is, I use this same pattern in other view controllers, and the compiler seems to be fine with those.

For the record my Code Generation -> Optimization Level was set to None for debug and release.

Hope this helps someone! It took hours to figure this out.

Solution 7 - Ios

It happened to me when I didn't put the parenthesis at the end of a call of a function:

let var = self.getNextPrimeNumber

solved it by:

let var = self.getNextPrimeNumber()

Solution 8 - Ios

In my case, it was caused by duplicate files, using the same name, in my project directory. As soon as I removed them, the error was gone.

Solution 9 - Ios

This happened to me when I used static inline function from swift file

The function looks like this

static inline void openURLInSafari(NSString * _Nonnull urlString) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];}

Solution 10 - Ios

this error comes from missing files so the compiler couldn't find the files and keep alerting. Follow these steps to rebuild your app:

  1. Look up for the red and invisible files within workspace
  2. Remove their reference
  3. Re-add files
  4. Re-compile

Solution 11 - Ios

I just had the same thing occur. I hunted down the cause to one file that caused the error even when empty. Examining the file, I discovered it had the wrong character set. When I set it to UTF-8, the error vanished. I think that it was decoding it with the wrong character set.

From this I surmise that the error simply indicates that something has happened that the compiler was unprepared for. Sorry that isn't very helpful to most people, but it may help to check your characters sets.

Solution 12 - Ios

This error occurred for me after I noticed that a few of my .swift files were inexplicably in the wrong directory -- one level above my Xcode project directory. When I noticed this, I moved them into the main project directory and cleaned the project, thinking everything would be fine. However, upon building the project I got the above-mentioned "failed with exit code 1" error. Just above the error message it listed the files I had just moved, indicating that it couldn't find them in the directory where they used to be. In addition to the error message, the files I moved were now showing up as red in the file navigation pane.

For each of the files in question what I did to resolve this was:

  • Select the file from the list of files in the Xcode file navigation pane,
  • Click on the little page icon in the rightmost pane of Xcode, which opens a file attributes pane,
  • Click on the little folder icon underneath where it says "Location" in the file attributes pane,
  • Choose the new location for the file,
  • RESTART Xcode for the above changes to really do anything.

Solution 13 - Ios

one more case that can lead to this error which just took me hours to track down: a failable initializer that always returns nil.

i had an initializer that looked like this:

init?(object: MyObject) {
    if object.importantProperty {
        // initialize
    }
    return nil
}

when what i meant was:

init?(object: MyObject) {
    if object.importantProperty {
        // initialize
    }
    else {
        return nil
    }
}

fixing the initializer made the error go away.

Solution 14 - Ios

If using Core Data:
I had a Core Data entity for which I created the NSManagedObject subclasses (with Xcode's help). In addition, the entity was configured to generate code automatically (see screenshot), so basically 2 classes existed during runtime. Just switch the option to Manual/None and it won't generate it.

enter image description here

Solution 15 - Ios

I experienced this error after performing a git merge. I solved new Xcode warnings and the project can be compiled.

Xcode 7.2.1 is used in my case.

Solution 16 - Ios

In my way the error was due to UIDevice.currentDevice() in ((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0)

After commenting this all starts work fine.

XCode 7.2

Solution 17 - Ios

in my case , at your project target Build Setttings, in Other Swift Flags,jsut delete the String "-serialize-debuggin-options" enter image description here

Solution 18 - Ios

In my case, the error was the result of missing files that were generated by Xcode. I tried the regular clean Opt+Shift+K and it didn't clean up all the errors. I found a post on the Apple Developer site that recomended going to the Product Menu in Xcode, holding down the opt key, and selecting Clean Build Folder. This appears to be a more comprehensive build as it pops up a modal dialog for you to confirm.

Solution 19 - Ios

I had a resolution very similar to RyanM, where with an excess of hubris I tried to assign a variable to the default value of an inner function:

Fails to compile (though does not crash SourceKit):

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    func itemCell(_ indexPath: IndexPath = indexPath) -> UITableViewCell {//...}

Succeeds:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    func itemCell(_ indexPath: IndexPath) -> UITableViewCell {//...}

Solution 20 - Ios

One possible reason that this can happen is perhaps because you have deleted a file but not removed references to it. This will mess up the pbxproj file. I would check to see if that is the case.

Solution 21 - Ios

check "Development Pods" Folder all listed Frameworks path.

Solution 22 - Ios

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

  1. keep 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 Happy Coding!!!

Solution 23 - Ios

So, I had the above and narrowed it down to a TFS issue with locking the file but only when I pasted or did any other edits besides small copies or manual typing. I noticed the original file would compile, but my edits wouldn't, even though they were syntactic OK. Also related is unable to save document: https://stackoverflow.com/questions/4089450/xcode-the-document-could-not-be-saved

The fix for both was:

  1. Duplicate working version.
  2. Paste fully-merged new code into duplicate.
  3. Copy and paste old file over new one. (I personally just renamed the old one to something else, then pasted duplicate and renamed it, too. Guessing both work since I pasted directly earlier for reverts during tests to see).

Voila. Lazy way to bypass merge-locking issue. Apparently full file-pastes are just fine, while edits aren't. Shared since the other answers don't seem to be as lazy as this. ;) Note: I am suspecting a non-UTF-8 character made its way somewhere, but pastes worked in older versions so I don't know where, or if relevant.

Solution 24 - Ios

Just go to the "project setting" and click on the "build phaces" after that you will find targets in that u have to delete the test file like my project name "WER" so its showing like this WER&TEST so just delete that and clean ur project and run .........

Attributions

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
QuestionR_DeveloperView Question on Stackoverflow
Solution 1 - IosMark McCorkleView Answer on Stackoverflow
Solution 2 - IosHenry FView Answer on Stackoverflow
Solution 3 - Ios庄景鹏View Answer on Stackoverflow
Solution 4 - IosFARAZView Answer on Stackoverflow
Solution 5 - IosMihriban MinazView Answer on Stackoverflow
Solution 6 - IosRyanMView Answer on Stackoverflow
Solution 7 - IosdanywarnerView Answer on Stackoverflow
Solution 8 - IosDimitri TView Answer on Stackoverflow
Solution 9 - IosM.OthmanView Answer on Stackoverflow
Solution 10 - IosJane chickenView Answer on Stackoverflow
Solution 11 - IosOwen GodfreyView Answer on Stackoverflow
Solution 12 - IosClayJView Answer on Stackoverflow
Solution 13 - IoscforkishView Answer on Stackoverflow
Solution 14 - IosShaked SayagView Answer on Stackoverflow
Solution 15 - IosoOEricView Answer on Stackoverflow
Solution 16 - IosvkalitView Answer on Stackoverflow
Solution 17 - IossunshineView Answer on Stackoverflow
Solution 18 - IoscurtView Answer on Stackoverflow
Solution 19 - IosStanView Answer on Stackoverflow
Solution 20 - IoshaxgadView Answer on Stackoverflow
Solution 21 - Iosuser9014721View Answer on Stackoverflow
Solution 22 - IosMRizwan33View Answer on Stackoverflow
Solution 23 - IosStephen JView Answer on Stackoverflow
Solution 24 - IosTejuView Answer on Stackoverflow