Skip to content

Conversation

Iron-Ham
Copy link

@Iron-Ham Iron-Ham commented Mar 13, 2025

Closes #190

Since xclogparser was last updated, there have been various changes in the way that Xcode builds are handled:

  1. The prefix for swift compilation steps is now SwiftCompile, not CompileSwift. This changes build step recognition in BuildStep.swift, but also changes the various regular expressions used for identifying these steps.
  2. Standard swift compilation steps are now batch compilation steps – similar in behavior to the swiftAggregatedCompilation step that is already defined. You can read more about that here: https://github.com/swiftlang/swift/blob/main/docs/CompilerPerformance.md#compilation-modes
  3. 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:

  1. Since these compilation steps are all batch steps… while this does cause the Slowest Swift Files to appear in the HTML reporter, this isn't really even a valid metric anymore since it's the measurement of n file compilations. XYZ.swift didn'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.
  2. This represents a hard version upgrade. It will not work for older versions of Xcode that don't use this build system.
  3. I haven't tested single file compilation mode.
  4. 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:

Changes to improve handling of Swift function and type check times:

Conformance to Hashable protocol:


Screenshots and Outputs

HTML Screenshot

Screenshot 2025-03-13 at 10 28 22 AM

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"
      }
    ]
  },

Signed-off-by: Hesham Salman <iron-ham@github.com>
@AvdLee
Copy link
Collaborator

AvdLee commented Jul 14, 2025

@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?

Copy link
Collaborator

@AvdLee AvdLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you been able to run the tests locally successfully after your changes?

Copy link
Collaborator

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lifting the support to Xcode 16 and onwards is sensible. I'd make sure this is reflected in the docs/README and also that we fail early if we detect an Xcode < 16 activity result is being processed with these changes. Otherwise it'll be difficult for the developer to diagnose issues.

switch signature {
case Prefix("CompileC "):
return .cCompilation
case Prefix("CompileSwift "):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since which Xcode version was this introduced?

@AvdLee
Copy link
Collaborator

AvdLee commented Sep 11, 2025

@Iron-Ham any updates on this PR? 🙏

@Iron-Ham
Copy link
Author

@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

@AvdLee
Copy link
Collaborator

AvdLee commented Sep 11, 2025

@Iron-Ham thanks for the heads up, that timing works! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swift Type check and functions build times not generated

4 participants