Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix XCLogParser function/typechecking recognition for modern Xcode versions #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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
1 participant