12

I've got the following problem: I've written my first Swift App (for iOS7) and it worked fine. After changing some minor detail (adding a string somewhere) it wouldn't compile anymore, even if I changed everything back how it was before.

There is no error message or anything like it, it says that it's building the project (Compiling Swift Source Files) but it's not progressing at all, even after hours of "building".

I've tried it with Xcode 6 b1 and b2 and with both it's the same: all the other projects are compiling without any problems, this one get's stuck.

Does anyone have a clue what might be the problem and how to solve it?

jscs
  • 63,694
  • 13
  • 151
  • 195
Luca
  • 163
  • 1
  • 5

5 Answers5

16

Debug the code manually works for me.

Finally I find the root cause of my problem is too many string concatenation in one line.

Bug code:

var string = string1 + string2 + string3 + string4 + string5 + string6 + string7 + string8 

Fixed code:

var string = string1
string += string2
string += string3
string += string4
string += string5
string += string6
string += string7
string += string8
Zhenshan Yu
  • 211
  • 1
  • 4
  • I had the same issue. Xcode hangs indexing files when assigning a long concat to a String. I don´t think it is a compiler issue, but rather an Xcode bug. I checked Xcode 6 betas 2 through 4 with the same result – eharo2 Jul 21 '14 at 20:12
  • The same thing happened for me when creating a large dictionary literal like `["myString": myVariable]` but with 20 objects. – tfrank377 Oct 02 '14 at 22:19
  • Xcode sucks. I removed the use of a literal array with more than 10 objects and it compiles now. –  Oct 09 '14 at 01:14
  • 1
    Same thing for me, but with array concatenations. – Devin Jan 03 '15 at 18:10
2

Xcode 6 Beta sometimes does not show any error but there will be some errors in your code. Because of that it does not compile.

Try to comment different parts of code and then try to compile. You have to find out the error manually.

I had this issue because I had some errors in my code but it was not showing.

Debug it manually. All the best.

neowinston
  • 7,584
  • 10
  • 52
  • 83
vntstudy
  • 2,038
  • 20
  • 24
1

Xcode 6 Beta 5 went into a tailspin for me immediately after I wrote out an expression to concatenate 3 strings and an NSDate object with the "+" operator.

Wouldn't compile and got stuck indexing.

Search your code for long string concats and remove for now. This is clearly a bug.

Sam
  • 2,745
  • 3
  • 20
  • 42
0

Several things you can try:

  1. Clean the project: Product -> Clean
  2. Go to Product try other options such as Analyze or Profile, see if it still stuck on build.
  3. Restart xcode
  4. Reboot System
  5. Open system console and try to trace the problem.
  6. Last but most importantly, really, because they are beta version, there will be some unexpected bugs. If it still cannot be solved, please report it to Apple and expect it to be fixed in beta 3.

  7. Based on your comment, go to Terminal and type in: defaults write com.apple.dt.XCode IDEIndexDisable 1

Anton
  • 559
  • 2
  • 15
  • Thx for your quick answers. Unfortunately I've tried all of that and nothing worked. But I've realized that the indexing seems to be the problem. When I lauch Xcode it start's indexing (processing files) but it never finishes.. Could I clean up something there or even disable it? – Luca Jun 19 '14 at 19:14
  • Check out my update on the answer, it can be disabled – Anton Jun 19 '14 at 19:17
  • I've read that somewhere before and now tried it once again but it doesn't seem to stop it. Xcode is still trying to index the project.. and then gets stuck. – Luca Jun 19 '14 at 20:08
  • killall -KILL XCode, do this in terminal – Anton Jun 19 '14 at 20:56
  • 2
    This successfully disables the indexing.. but now it just lags when it's building the app.. – Luca Jun 19 '14 at 21:55
0

This bug will relate to our project state and source code. I rolled back some commits of my project, xcode succeeded indexing my project.

In my case, xcode failed to index, when my project has a declaration of large dictionary. (I succeed indexing after removing it.)

Mitsuaki Ishimoto
  • 3,162
  • 2
  • 25
  • 32