4

When i had open my build result to see what is slowing my compilation, all my classes have a lot of this:

0.1ms   <invalid loc>   get {}
0.2ms   <invalid loc>   init?(rawValue: Int)
0.1ms   <invalid loc>   get {}
0.2ms   <invalid loc>   init?(rawValue: Int)
0.1ms   <invalid loc>   get {}
7.3ms   <invalid loc>   get {}
0.2ms   <invalid loc>   get {}

Someone can help me?

Renato Ioshida
  • 421
  • 3
  • 6
  • Try to clean the project, throw derived data away, rebuild? – 0x416e746f6e Nov 21 '16 at 11:45
  • @AntonBronnikov Yeah my friend, more than one time! – Renato Ioshida Nov 23 '16 at 18:19
  • I have the same issue. My project is quite big and I have around 500.000 occurences of invalid loc. – Marco Pappalardo Mar 02 '17 at 09:32
  • @MarcoPappalardo how did u resolved this problem? – Renato Ioshida Mar 02 '17 at 16:53
  • @RenatoIoshida I did not :( I wait 10 minutes every build. The get{} are most probably calls to closures or map {}. The problem is that the compiler checks the closures everytime it starts compiling a new file. Hence if you add more files, the closures will be type checked a million of times, so build time increases exponentially. The main solution to test this would be to remove all closures and map from your code and verify that the build becomes faster and you don't get these invalid loc anymore. in my case we have too many of them to remove them, so we are post-poning the "fix" – Marco Pappalardo Mar 02 '17 at 17:08
  • @RenatoIoshida also, try to explicity set the type of all your variables. If you let the compiler infer the type, it takes quite some time. In some cases, if you nest collections inside collections and you do not provide the full type for it, the compiler can take hours to actually understand what it should do: http://stackoverflow.com/a/28255769/1547593 – Marco Pappalardo Mar 02 '17 at 17:10
  • see https://kerrick.wordpress.com/2016/09/13/how-i-escaped-a-swift-compiler-hang/ – Zsolt Apr 17 '17 at 09:22

0 Answers0