I cleaned the build folder with cmmd + shift + K
'Compile Mode' set in the Build Settings. It's set to incremental.
Using: Xcode 13.3.1
For every single file that is compiled, I see almost an exact number of files marked with -primary-file
. However my understanding of the swift-frontend --help
was that, for compiling a single file, only that single file should be marked as -primary-file
. ChatGPT also confirmed this
Example the logs for compiling CoolVC.swift are as such. Every file is marked with -primary-file
.
CompileSwift normal x86_64 path/to/MyModule/CoolVC.swift (in target 'MyModule' from project 'Pods')
cd /Users/mfaani/Dev/MyModule/main/Example/Pods
/Applications/Xcode13.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -filelist /var/folders/gp/q_jsdfkjasdkfas0t2tz_s640000gp/T/TemporaryDirectory.k7DLR8/sources-1
-primary-file path/to/MyModule/Constants/Segues.swift
-primary-file path/to/MyModule/CustomViews/SettingsView.swift
-primary-file path/to/MyModule/CoolVC.swift
< A LOT MORE FILES>
-primary-file path/to/MyModule/LoaderVM.swift
-primary-file path/to/MyModule/Utilities/SwiftUI/Shadow.swift -supplementary-output-file-map
I've tried inspecting the logs in a number of different scenarios:
A have a workspace with app project + dependencies project:
- Fresh build after clean:
- For code in app project I only see a single
-primary-file
being used to compile a swift file - For code in dependencies project I only see multiple
-primary-file
along withfilelist
option being used to compile a swift file
- For code in app project I only see a single
- If I make a single change to a swift file from my dependencies project, then within the compilation of CoolVC, I see a single file marked as -primary-file.
For another simple app straight out of Xcode's app template, when I build for the first time, I only see a single file being marked as -primary-file
. I even tried making it so that the code in foo.swift depends on bar.swift which depends on baz.swift, but still I got the expected i.e. a single file was marked as -primary-file
So is there an explanation as to why in the dependencies project, only the first time I see multiple/all files marked as -primary-file?
(both repos/projects have 'Compile Mode' set to incremental)
2nd Question:
When the number of files in the module are A LOT, I don't see all the file mentioned for the CoolVC.swift mentioned. For every file in the module I see almost identical 25 swift files marked with -primary-file along with a filelist, which gets created and goes into ether after compilation is finished. meaning I can't inspect it. But I suppose it contains the list of all files of the module.
My question is, why is there a mix and match. Why not just mention the filelist and be done? Why is there both file along with 25 swift files explicitly mentioned?