0

I am running Xcode 12.5.1 on Big Sur 11.6 I have been building apps with Xcode for more than four years. Lately I have one app that all too frequently throws the following error:

Illegal Instruction: 4

I am using Swift with UIKit and a combination of Storyboards, Xibs and programmatic code.

I have searched extensively for a solution and have seen this stackoverflow post more than once in my quest. The most popular response is dated and this problem only happens on one specific app. I have reinstalled Xcode, I have rebooted, re-cloned the repository and cleaned the build folder until it is spotless. Co-workers do not experience the issue with the same repository.

How can I troubleshoot the root cause of this annoying error?

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
forrest
  • 10,570
  • 25
  • 70
  • 132
  • 1
    More details, please - you haven't even said what language you are coding in. The only generic answer that can be given at this level is "use your debugger to see where the error is being produced, then try to figure out why". – Nate Eldredge Oct 13 '21 at 00:52
  • Added details to the description. Using Swift with UIKit. – forrest Oct 13 '21 at 00:56
  • A few wild guesses: (1) undefined behavior in a compiled language, where the compiler decides to deliberately execute an illegal instruction and crash the app when the undefined behavior is reached; (2) compiler options or inline assembly are set to use instruction set extensions that your particular CPU doesn't support; (3) some code is being compiled or selected for an incorrect architecture; (4) corrupted function pointer is jumping to an incorrect address – Nate Eldredge Oct 13 '21 at 00:58
  • Thank you for the feedback. I'll keep searching. – forrest Oct 13 '21 at 01:08
  • Maybe you could add **something** that I could reproduce? What you have doesn't help. –  Oct 13 '21 at 02:48
  • I wish I could add **something** you could reproduce. As per my question, I am trying to determine the root cause of this issue. – forrest Oct 13 '21 at 13:08

3 Answers3

0

I found the answer in the most unlikely of places. A co-worker pointed me to this post.

forrest
  • 10,570
  • 25
  • 70
  • 132
0

It may be the currently opened project file, the new version of Xcode has been run, and you are using the old version of Xcode to open。

like: current project file is running well on Xcode 13.4.1, but if your using Xcode 13.0 to open, then will be show "Illegal Instruction: 4".

please make sure using the same Xcode or New version

JNYJ
  • 515
  • 6
  • 14
0

Try setting the compilation mode to Whole Module Compilation.

Jayant Jaiswal
  • 171
  • 1
  • 8