Jonathan
Jonathan

Reputation: 2983

Xcode throws random errors when there are none

Every once in a while, usually after I've done some trial and error on my code, Xcode throws random errors at me even though I've removed the previous incorrect code snippets, and even though I've restored my files to a stage where it last worked perfectly. In other words, there are no errors for sure, yet my app crashes and Xcode generates errors. I shall also add that when my iPhone isn't connected to my computer, the app runs just fine.

After having removed everything that did cause errors in the past, Xcode - as described above - instead points to random stuff as being incorrect such as closing brackets, viewDidLoad, as if saying: "Hey, I know there was an error before, can't find it now though but I know it's there somewhere so lets crash and point at something completely random such as a closing bracket".

I assume the old project files are being cached (or similar) somewhere but I can't for the life of me figure out where or how to get rid of them. I'm using Xcode 4.5.2, iPhone 5 iOS 6.0.2, OSX 10.8.2 fwiw.

What I've tried so far:

  1. Clean, build, run, clean, rebuild, re-run. [no change]
  2. Restart X-code, remove icon from home screen, step 1 again [no change]
  3. Restart computer [no change]
  4. Restart iPhone and simulator and reset simulator to factory settings [no change]
  5. Delete the Derived Data from organizer as shown here, and suggested here [no change]
  6. All above including restoring my entire iPhone [Works]
  7. Create a new project and rebuild the nib file and copy past code from old project to new [Works]

Yes, alternative 6 and 7 do work but I can't spend hours on restoring my iPhone to factory settings or recreate my entire Xcode project every time this happens. Alas, it does happen quite often these days.

Any other ideas or suggestions?

Upvotes: 4

Views: 1275

Answers (1)

Jonathan
Jonathan

Reputation: 2983

Thanks to gmogames for pointing out the following solution which did the job for me.

In Xcode press:

Option + Shift + Command + K

Upvotes: 3

Related Questions