3

I'm working on an iPhone game and have now a big problem.

The project is getting larger and larger. Now Xcode takes forever for indexing, typing is laggy, autocomplete takes some seconds, building the file takes forever and so on.

Im using Xcode 8 Beta 6, but that is not the problem. If i open another project which is not so big the performance is normal.

I deleted the files under DerivedData but that did not help.

My question is: In this big project I have one GameScene.swift file with 7500 lines of code. Is that causing the problem? Or should Xcode be able to perform this much code in one file and the problem is more the code itself? Ive read that for example the syntax of an array can cause the problem, or if you declare an array with 30 or more objects (both not the case for me).

I think it's something inside the code which causes the problem and not the size of the code - but I don't know how to find it out.

Edit: Oh, the process SourceKitService has almost always 100% CPU use.

Cœur
  • 37,241
  • 25
  • 195
  • 267
aignetti
  • 481
  • 1
  • 3
  • 14
  • 7,500 lines of code? Are you jamming all of your code into that one file? – Kendel Aug 28 '16 at 16:11
  • 3
    I don't know if it's the cause or not, but I'd consider 7500 lines in one file to be quite a lot. It's all dependent on circumstances but, if I hit 2000, I start to wonder if I've overdone it for that class. – Phillip Mills Aug 28 '16 at 16:11
  • 1
    It's not the issue with the project size. I've a project which have around 1K classes and around 10K resources and other kind of files in it and all is working fine. But I met a similar situation in one of my other project, the issue was with a line of code that does some kind of logic check and appends a string. After I wrote that code my Xcode started behaving like the above mentioned way, first I thought my RAM is full so, closed all the application, restarted the machine nothing worked. Then I thought a possible virus attack. – Midhun MP Aug 28 '16 at 16:13
  • After some research I found that SourceKit and Swift are the processes which takes 90% of my RAM usage. And found an answer on SO, which helped me to re-think and fix the issue. http://stackoverflow.com/questions/26151954/sourcekitservice-consumes-cpu-and-grinds-xcode-to-a-halt – Midhun MP Aug 28 '16 at 16:16
  • You didn't say what machine you have. My Xcode projects which are super fast on a modern machine are totally unusable due to slowness on older macs. – Gruntcakes Aug 28 '16 at 16:17
  • I've found with perfectly reasonable sized projects, 1500 lines of code in the longest file, 12000 lines total over 40-50 files, modest storyboards, that SourceKit is wildly unreliable CPU eater and I have to disable it and put up with lack of code completion as the only solution. http://stackoverflow.com/questions/13959709/stopping-xcode-from-indexing. This is on a top of the line Mac Air i7 8GB RAM. – BaseZen Aug 28 '16 at 16:52
  • MacBook Pro Intel Core i5 with 2,7 GHz and 8GB RAM. RAM is not the problem - in the activitymonitor there is everything normal, it is the CPU usage. I find out that i have a function which works 7437.3ms while building. It includes many randomInt functions - maybe that is the problem .. – aignetti Aug 28 '16 at 16:53

0 Answers0