Xcode compile swift file repeatedly


(Zeng Sir) #1

Some swift source file has been compiled more than 50 times, every time take 599ms, so it takes 50 * 599ms.

Why is this? And how can I optimize it?

Here is some logs:

Through this tool (BuildTimeAnalyzer-for-Xcode), I got this result:

And I got the same result with Xcode build log file:

There should be another image, but I got the error "Sorry, new users can only put one image in a post." when submit. But it not affect anything.

Others Description

The project was consist of 1200 swift files and 400 OC files, some third part library is orgnized by cocoapods.

Total compilation time:4m 38s

EVN
MacBook Pro (Retina, 15-inch, Mid 2015)
2.2 GHz Intel Core i7
16 GB 1600 MHz DDR3
Xcode 10.1
swift 4.2


(Zeng Sir) #2

Xcode log is here:


(John McCall) #3

(Zeng Sir) #4

I found a similar problem on stackoverflow, but I still didn't see the specific cause and solution.


(Jacob Williams) #5

I too have seen the Build Time Analyzer report that some files are compiled several times in certain projects. In my case it was always pure SwiftPM projects and the files were generally only compiled 5-10x (not 50).