Xcode is compiling all Swift files one at a time?

I have two apps; one is a subset of functionality of the other. The smaller app has about 170 Swift files. The larger app has these files plus about 120 more. So I would expect the larger app to take around twice as long to build.

Instead, the smaller app takes less than a minute to build while the larger app takes over 13 minutes to build; to be exact, it takes 15.3 times longer.

While reviewing the build report, I noticed that the smaller app compiles the Swift files in batches, with each batch taking around 10 seconds, but with up to 17 batches running at once. In contrast, the larger app compiles all 290 Swift files in one giant batch, so apparently there is no multithreading of the Swift compilation (see screen shots below). The difference in the number of batches the smaller app compiles at once roughly corresponds to the difference in overall build time.

Is there a build setting I can change to make the larger app compile Swift files in multiple smaller batches as the smaller app is doing? I checked SWIFT_COMPILATION_MODE and it's the same in both apps (Incremental for debugging and Whole Module for release) but I don't know what other settings I should check.

Answered by arlomedia in 877158022

I found it! I searched the build settings for "build" in both apps and just went down the list, comparing every setting. The only difference was User Script Sandboxing, which was Yes in the smaller app and No in the larger app. When I turned that on in the larger app, it built files in batches like the smaller app, and finished in 38 seconds -- that's 21 times faster than before. This is going to make release days so much easier.

Accepted Answer

I found it! I searched the build settings for "build" in both apps and just went down the list, comparing every setting. The only difference was User Script Sandboxing, which was Yes in the smaller app and No in the larger app. When I turned that on in the larger app, it built files in batches like the smaller app, and finished in 38 seconds -- that's 21 times faster than before. This is going to make release days so much easier.

Xcode is compiling all Swift files one at a time?
 
 
Q