7

I just used Xcode 7's migration tool to migrate a project from Swift 1.2 to 2. After fixing up errors missed and such, all is well except for an error which prevents me from even building: Command failed due to signal: illegal instruction 4.

I have tried the help in these articles (Xcode 7 and Swift 2.0 : Command failed due to signal: Abort trap: 6, and Command failed due to signal: Abort trap: 6) which are not identical issues to mine, but nevertheless they were not able to fix the issue.

I have cleaned the build and removed the derived data folder. I have up to date CocoaPods installation, Xcode tools are at 7.0, and I Swift compile optimization is at None. Is there anything else I'm missing?

Thanks!

Community
  • 1
  • 1
BJ Miller
  • 1,536
  • 12
  • 16
  • 1
    I had the same issue, in my case I had two classes and a protocol: `class A: B, P` but `class B` had a property enforced by `protocol P`. For some reason, not including the protocol in the class that really had the property was causing this error. I just made `class B` include the protocol and the error went away! – dcestari Jun 16 '15 at 12:19
  • Thanks @dcestari, was there a build error showing up for you that helped you find this? Or was it just random chance? – BJ Miller Jun 18 '15 at 20:31
  • Yes @bj-miller but they were not clear, I just saw similar things to `ref myAttribute` (assuming the `myAttribute` was the name of the property) and `ref B`. – dcestari Jun 22 '15 at 17:36
  • I see. I did see in the build error that it was referring to a particular file that is a superclass to 5 subclasses, as it has a few methods shared among all children. So now I'm re-watching Protocol-Oriented Programming to see if I can rewrite it ;-) Thanks for the reply @dcestari – BJ Miller Jun 22 '15 at 17:38
  • Please file a bug at https://bugreport.apple.com and include the crashlog, and if possible the project or a reduced case which causes the crash; then please post the bug number here. – Flash Sheridan Jun 25 '15 at 16:04

2 Answers2

7

So an answer was found thanks to the help of a coworker. We found the offending file in the build error, but there was no line provided. Through process of elimination, we found it to be a line that was declaring a new constant to the result of getting a JSON dictionary ([String : AnyObject], typealiased to JSONDictionary), from inside an optional dictionary. Here is the line:

let objectsDictionary = maybeJSON?[key] as? JSONDictionary

Changed this to two guard statements:

guard let goodJSON = maybeJSON as? JSONDictionary else { return ... }
guard let objectsDictionary = goodJSON[key] as? JSONDictionary else { return ... }

This line worked in Xcode 6.3.2 as it would just provide an optional value, but for some reason, some change in Xcode 7 didn't like this. I hope this can help anyone else who runs across this.

BJ Miller
  • 1,536
  • 12
  • 16
2

'Illegal instruction' simply means that your binary contains instructions that are invalid for the type of architecture you are trying to run the code with. Start looking at the minimum version in your project build settings.

John Difool
  • 5,572
  • 5
  • 45
  • 80
  • Minimum version was set to 7.0, even changing to 8.0 or 9.0 still results in same error. – BJ Miller Jun 13 '15 at 18:22
  • Are you getting the error when building for the simulator or the device? – John Difool Jun 13 '15 at 18:47
  • Both. iOS simulator 8.1 and 9.0, as well as device (iPhone 5s on iOS 9 beta). The build phase itself fails, I don't even get to run it. – BJ Miller Jun 15 '15 at 15:14
  • Something is fishy. I would look at the libs you are including and evaluate if there are some rogs in there. – John Difool Jun 15 '15 at 22:02
  • Good idea. I'll remove all pods and refs to them and try that. Thanks for the tip, I'll reply later tonight. – BJ Miller Jun 15 '15 at 23:43
  • No dice...I'm stumped. Removed pods from Podfile (only KSReachability, Lockbox, SVProgressHUD, and SMPageControl), and removed .xcworkspace file. Cleaned, still nothing. I'm gonna put this on the back burner until another beta comes out to see if something there resolves this. Thanks for all your help! – BJ Miller Jun 16 '15 at 02:30
  • Didn't work. I had originally set my Deployment Target to 8.0, but even changing it back to 9.0—when it was working fine—and cleaning and running hasn't eliminated the error. – Canucklesandwich Sep 03 '15 at 13:17