Xcode 7, Swift 2.0, odd "trap 6" with odd solution

TL;DR

I got "trap 6" error when I tried to build my App. I tried to fix it for a whole day. I fixed it by simply cloning the repo to somewhere else and build it. It might be caused by some cached build file somewhere in the project folder, which is not tracked by version control.



Why I am certain it is caused by some cached file in that project folder


I tried "Clean" action in "Product" menu. I also tried deleting "Derrived Data" folder in "Project" window. None of these helped.

I also tried to checkout my master branch, which I know it should build. But I got the same error which makes no sense.

I created some demo project to mimic the minimal setup of my App. All of them can be built without any error.


I cloned my repo somewhere else and checked out the exact commit which is giving me "trap 6" error. Build, succeeded!

I copied the original "trap 6" folder to somewhere else, I still got the same error.


PS.


Another thing is that, I got this error when I was using Xcode 7 beta. I updated to beta 2 because I see someone said that beta 2 fixed this problem in this forum. After updating to beta 2, I still got this error.


--------

I spent my whole day trying to debuging where the error came from. WASTED... 😟

I hope this post can help others and save someone's time.


EDIT:


I just found out why I was getting "Abort trap 6". Whenever I put one of my struct as a parameter of a `init` and try to access its variables, it happens.


My struct is just a plain Swift struct which conforms to `Decodable` in Argo, the functional JSON decoding framework by thoughtbot.


The whole snippet compiles, until you uncomment that marked line.

import SwiftDailyAPI 

class T { 
    init(newsMeta: NewsMeta) { 
        print(newsMeta) 
        // Uncomment the next line, and "Abort trap 6" you will have 
//        print(newsMeta.newsId) 
    } 
    func t(newsMeta: NewsMeta) { 
        print(newsMeta) 
        print(newsMeta.newsId) 
    } 
}

Thanks, I had the same problem, spent about half a day, will try re-cloning the project!

If you hold down the option key, the "Clean" menu item (in the "Product" menu) turns into "Clean Build Folder...".

It might get whatever cached data was causing the issue, that Clean misses (particularly if you have multiple interdependant projects in your workspace).

Just tried "Clean Build Folder" in the original project. Still getting "abort trap 6".

Did you look at the build output to see if the compiler asserted during compilation?


I believe you may find that it does, in which case it would be great if you could file a bug with a project attached that reproduces the problem (either the project you're seeing this in, or some reduced version of it that still demonstrates the problem).

Yes, there is one assertion falling.


I just found out why I was getting "Abort trap 6". Whenever I put one of my struct as a parameter of a `init` and try to access its variables, it happens.


The whole snippet compiles, until you uncomment that marked line.

import SwiftDailyAPI

class T {
    init(newsMeta: NewsMeta) {
        print(newsMeta)
        // Uncomment the next line, and "Abort trap 6" you will have
//        print(newsMeta.newsId)
    }
    func t(newsMeta: NewsMeta) {
        print(newsMeta)
        print(newsMeta.newsId)
    }
}


I tried to file a bug report, twice. But after uploading my attachments, it failed with a error says something like "JSON Parse parameter ... RAW". Are there some restrictions on what kind of file you can upload?


EDIT:


Bug report is filed successfully, 😀

Bug report number: 21559246

Glad to hear it - thanks for taking the time!

Xcode 7, Swift 2.0, odd "trap 6" with odd solution
 
 
Q