Fix XCLogParser function/typechecking recognition for modern Xcode versions
Closes https://github.com/MobileNativeFoundation/XCLogParser/issues/190
Since xclogparser was last updated, there have been various changes in the way that Xcode builds are handled:
- The prefix for swift compilation steps is now
SwiftCompile, notCompileSwift. This changes build step recognition inBuildStep.swift, but also changes the various regular expressions used for identifying these steps. - Standard swift compilation steps are now batch compilation steps – similar in behavior to the
swiftAggregatedCompilationstep that is already defined. You can read more about that here: https://github.com/swiftlang/swift/blob/main/docs/CompilerPerformance.md#compilation-modes - As an addendum to (2): Since these batch steps are asynchronous and parallelized, there are situations where substep function and type check times may be duplicated. As such, we ensure we're de-duplicating them by passing them through a
Set.
In short: this allows the type checking and function time data to appear in the outputs without causing memory explosions or runtime explosions.
Things to note:
- Since these compilation steps are all batch steps… while this does cause the
Slowest Swift Filesto appear in the HTML reporter, this isn't really even a valid metric anymore since it's the measurement of n file compilations.XYZ.swiftdidn't take 20 seconds to compile – rather, it and its batch of files took that time. We should probably fully remove this section from the HTML output, unless the compilation mode is setup for single files. For now, I'm leaving it as is. - This represents a hard version upgrade. It will not work for older versions of Xcode that don't use this build system.
- I haven't tested single file compilation mode.
- Module time compilation isn't reporting any differently than it was previously, however, I always found this to be a somewhat flawed metric: it's showing the aggregate time of the module and its dependencies. If we have a 5 line module that depends on a gigantic module, we often run into the situation where the small module reports a compilation time ~1s larger than its dependent module.
🤖 Copilot Generated PR Description and Outline
This pull request includes several changes to improve the parsing and reporting of Swift compilation steps in the XCLogParser project. The changes focus on updating patterns for Swift compilation, enhancing data structures for performance, and refining the reporting logic.
Changes to update CompileSwift prefix:
-
Sources/XCLogParser/parser/BuildStep.swift: Updated the prefix fromCompileSwifttoSwiftCompilein theDetailStepTypeenum. -
Sources/XCLogParser/parser/IDEActivityLogSection+Parsing.swift: Updated the regular expression pattern to matchSwiftCompileinstead ofCompileSwift. -
Sources/XCLogParser/parser/ParserBuildSteps.swift: Changed the pattern inswiftcArchRegexpto matchSwiftCompileinstead ofCompileSwift.
Changes to improve handling of Swift function and type check times:
-
Sources/XCLogParser/reporter/HtmlReporter.swift: Replaced arrays with sets forswiftFunctionTimesandswiftTypeCheckTimesto avoid duplicates and ensure unique entries. [1] [2]
Conformance to Hashable protocol:
-
Sources/XCLogParser/parser/SwiftFunctionTime.swift: MadeSwiftFunctionTimeconform to theHashableprotocol. -
Sources/XCLogParser/parser/SwiftTypeCheck.swift: MadeSwiftTypeCheckconform to theHashableprotocol.
Screenshots and Outputs
HTML Screenshot
FlatJSON Output (Redacting app name)
Excerpt 1:
[
{
"type" : "main",
"fetchedFromCache" : false,
"errorCount" : 0,
"compilationEndTimestamp" : 1741873280.071251,
"errors" : [
],
"schema" : "<REDACTED>",
"compilationDuration" : 451.705482006073,
"endDate" : "2025-03-13T13:41:39.543000Z",
"detailStepType" : "none",
"startDate" : "2025-03-13T13:33:48.366000Z",
"parentIdentifier" : "",
"buildIdentifier" : "Hesham’s MacBook Pro_C73D272C-AA17-42E3-99B2-77AC929317F4",
"warningCount" : 143,
"notes" : [
{
"title" : "Run script build phase 'Set Bundle Version' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked.",
"startingLineNumber" : 0,
"type" : "note",
"severity" : 0,
"characterRangeEnd" : 0,
"detail" : "note: Run script build phase 'Set Bundle Version' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'PullsWidget' from project 'REDACTED')\rnote: Run script build phase 'Set Bundle Version' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'NotificationService' from project 'REDACTED')\rnote: Run script build phase 'Set Bundle Version' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'IntentsService' from project 'REDACTED')\rnote: Run script build phase 'SwiftLint' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'REDACTED' from project 'REDACTED')\rnote: Run script build phase 'Crashlytics' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'REDACTED' from project 'REDACTED')\rnote: Run script build phase 'Set Bundle Version' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'REDACTED' from project 'REDACTED')\r\/Users\/zer0\/Developer\/REDACTED\/mobile-ios\/.build\/Xcode\/DerivedData\/SourcePackages\/checkouts\/firebase-ios-sdk\/Package.swift: warning: DEFINES_MODULE was set, but no umbrella header could be found to generate the module map (in target 'Firebase' from project 'Firebase')\rnote: Run script build phase 'Set Bundle Version' will be run during every build because the option to run the script phase \"Based on dependency analysis\" is unchecked. (in target 'ContributionGraphWidget' from project 'REDACTED')",
"startingColumnNumber" : 0,
"endingColumnNumber" : 0,
Excerpt 2:
"documentURL" : "file:\/\/\/Users\/zer0\/Developer\/REDACTED\/mobile-ios\/Modules\/_REDACTEDMarkdown_Routes\/Sources\/UIResponder+WebViewPreviewable.swift",
"endDate" : "2025-03-13T13:40:00.822000Z",
"swiftFunctionTimes" : [
{
"file" : "file:\/\/\/Users\/zer0\/Developer\/REDACTED\/mobile-ios\/Modules\/_REDACTEDMarkdown_Routes\/Sources\/UIResponder+WebViewPreviewable.swift",
"startingColumn" : 17,
"signature" : "instance method _REDACTEDbMarkdown_Routes.(file).UIResponder extension.onPreview(url:)@\/Users\/zer0\/Developer\/REDACTED\/mobile-ios\/Modules\/_REDACTEDMarkdown_Routes\/Sources\/UIResponder+WebViewPreviewable.swift:7:17",
"durationMS" : 0.73,
"startingLine" : 7,
"occurrences" : 1
},
{
"startingColumn" : 17,
"signature" : "instance method _REDACTEDMarkdown_Routes.(file).UIResponder extension.presentPreview(url:)@\/Users\/zer0\/Developer\/REDACTED\/mobile-ios\/Modules\/_REDACTEDMarkdown_Routes\/Sources\/UIResponder+WebViewPreviewable.swift:11:17",
"durationMS" : 0.37,
"occurrences" : 1,
"startingLine" : 11,
"file" : "file:\/\/\/Users\/zer0\/Developer\/REDACTED\/mobile-ios\/Modules\/_REDACTEDMarkdown_Routes\/Sources\/UIResponder+WebViewPreviewable.swift"
}
]
},
@Iron-Ham what is the minimum Xcode version this will work with? I assume many of the users of this repo work with newer Xcode versions, so as long as it's Xcode 16 and up, we should be good. @pepicrft thoughts?
@Iron-Ham any updates on this PR? 🙏
@AvdLee apologies, I haven't had the time to dive back into this, and the context is a bit fuzzy at this point. Happy to take a look once some of the iOS26 dust settles on my end – likely tomorrow or this weekend!
Appreciate your patience
@Iron-Ham thanks for the heads up, that timing works! 🚀