-4

I tried to changed a "high score" bool to be true and play a certain sound when the user gets a high score. The sound itself worked fine, but it was when I tried to set it the sound to only play on the high score if (HighScoreBool == true) the app totally stopped working right.

Everything went grey and all I could see is the end of "high score" text in the bottom left corner. All images are gone, can't click anything, all I see is grey and a little bit of text in the bottom right.

I tried to undo, clean, and reopen up Xcode to no avail. At the moment, my project builds perfectly, launches perfectly (launch screen image works), even plays the background sound, but for some reason everything else is just gone besides a little of the high score text and the overall GREY screen.

Again, everything was working FINE until I tried to type this:

if (HighScoreBool == true) {SkAction playSound etc.}

And then the grey screen happened, and then even when I simply deleted the line of code to try to resolve the problem, the project still acted the same way: Grey Screen, text in bottom left corner.

Long Story Short: I feel like I've narrowed it down to the issue started when I attempting to write this: if (HighScoreBool == true) but when I deleted that, same issue.

Please provide some insight as to what is going on so I don't have to rewrite the entire app.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
JimmyAPPS
  • 1
  • 4
  • Absolutely impossible to tell from here. Probably you nuked some other part of the code or project while you were editing the High Score bits. Are you using versioning or TimeMachine like backups? Restore from before those edits and maybe your working code will be there. – rebusB Jun 07 '16 at 17:23
  • To break it down simply this is exactly what happened: I added the new line of code I though I wanted, built it, Launch Screen worked fine, Background Music started playing fine, but then I saw the app wasn't actually working right (Grey screen as stated above), so I went back pressed "undo"(Cmd+Z) to delete the new bad line of code and immediately re-ran it to test, and when it ran it was still showing up that "Grey Screen" mode! – JimmyAPPS Jun 07 '16 at 19:03

1 Answers1

2

Sometimes, Xcode can get out of whack. The IDE saves results of operations, and sometimes fails to clear everything, especially when you switch between branches a lot of times. Also, Xcode sometimes does not respond well, when switching between branches that include a dramatic amount of changes to the project file.

Try deleting derived data after cleaning your project and closing Xcode. You should only need to delete derived data if there's a strange error from Xcode or assets are out of whack. I submitted an answer that allows this to be done easily from the command line: https://stackoverflow.com/a/27977848/1231948.

If you're on a repo, you can also try stashing your changes and reset your branch. But, try this with Xcode closed, to lower the risk of locked files not being updated or deleted. Also try checking out an earlier commit, and then going back to the head. For me, that cleared an issue with my project that prevented a successful clean.

Community
  • 1
  • 1
Sheamus
  • 6,506
  • 3
  • 35
  • 61
  • Thanks for your reply!! I'm pretty new to developing, will deleting the derived data affect my app in any way? I am just a little worried as I don't want to mess anything else further (I have a second project open that I'm working on as well). I'm just astounded the issue can't be fixed by simply undoing/deleting the new line of code, I have never encountered this. I simply added the new line of code, built it, saw it ran weird with the grey screen, so I went back pressed "undo"(Cmd+Z) and immediately re-ran it to test, and low and behold its stuck in that "Grey Screen" mode! Very frustrating! – JimmyAPPS Jun 07 '16 at 19:01
  • No, deleting the derived data will not affect your app. The derived data is just what the name says--it is derived from building and other operations of Xcode to support building and deployment. – Sheamus Jun 07 '16 at 19:25
  • I'm editing the answer to include a link to deleting the derived data--I submitted another answer that allows it to be easily deleted, using the command line. – Sheamus Jun 07 '16 at 19:27