Azure DevOps CodeQL init causes SwiftPM unableToFind(tool: "clang") with Xcode 26.3

xu chen 0 Reputation points
2026-11-03T02:32:19.2566667+00:00

We are using an Azure DevOps Classic build pipeline on a Microsoft-hosted macOS agent to build an iOS project with Xcode 26.3 (build 17C529). The project uses Swift Package Manager. AdvancedSecurity-Codeql-Init@1 is configured for Swift in Manual build mode.

Pipeline order:

  1. Select Xcode 26.3.
  2. Run xcodebuild -resolvePackageDependencies (succeeds).
  3. Initialize CodeQL.
  4. Run xcodebuild archive using the Xcode task.
  5. Perform CodeQL analysis.

The archive fails before compilation while resolving SwiftPM dependencies again:

xcodebuild: error: Could not resolve package dependencies:
error: unableToFind(tool: "clang")
warning: Unable to locate libSwiftScan. Fallback to swift-frontend dependency scanner invocation.

Read-only diagnostics immediately after CodeQL initialization show that xcrun --find swiftc and xcrun --find clang both resolve to existing files in /Applications/Xcode_26.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin. DEVELOPER_DIR and TOOLCHAINS are unset. SEMMLE_COPY_EXECUTABLES_ROOT points to the CodeQL working/copy-root directory. Before archive, no compiler entries are present in copy-root. After the failed archive, a swiftc symlink appears under the prefixed Xcode toolchain path in copy-root, while our find command reports no clang entry there. We have not confirmed whether the missing copy-root clang entry is the root cause.

Troubleshooting: Package resolution succeeds before CodeQL initialization. The same project archives successfully when CodeQL Init and Analyze are disabled. Removing the SPM cache steps and custom cloned package directory did not change the clang error when CodeQL was enabled again. An experimental clang symlink in copy-root changed the failure to standard-header/Darwin-module errors, so we have not adopted that as a fix.

Is this combination of Azure DevOps CodeQL, SwiftPM, and Xcode 26.3 supported? How can we diagnose the tool lookup performed by SwiftPM under the CodeQL tracer, and is there a supported configuration or fix? The GitHub codeql-action maintainers directed us to Microsoft because the Azure DevOps integration is maintained by Microsoft: https://github.com/github/codeql-action/issues/4279

Azure DevOps

1 answer

Sort by: Most helpful
  1. AI answer

    2026-11-03T02:33:37.2866667+00:00

    No source confirms Xcode 26.3 as supported with the CodeQL bundle currently installed on the hosted agent, so update the Azure DevOps CodeQL task to obtain the latest bundle and, if the failure remains, collect the tracer database logs for Microsoft support rather than modifying the copied Xcode toolchain.

    Use the latest CodeQL bundle

    Swift is supported by GitHub Advanced Security for Azure DevOps, and Manual is the correct build mode: Swift does not support build mode None.^1^

    However, that general Swift support does not establish compatibility with every Xcode release. In particular, CodeQL CLI 2.23.3 was explicitly reported as not supporting Xcode 26.^2^ Your log must identify the actual bundle version before support for 26.3 can be determined.

    In the Classic pipeline:

    1. Open Advanced Security Initialize CodeQL.
    2. Keep:
      • Languages: swift
      • Build mode: Manual
    3. Select Enable automatic CodeQL detection and installation.
    4. Set Log level to Debug (2).
    5. Queue a clean run and record the CodeQL CLI/bundle version printed by initialization.

    The initialization task documents both enableAutomaticCodeQLInstall, which installs the latest version when the existing installation is absent or outdated, and debug logging through loglevel: 2.^3^

    Keep the required order:

    1. CodeQL initialization
    2. xcodebuild archive or the Xcode task
    3. CodeQL analysis

    Your pre-initialization dependency-resolution step may remain, but the traced archive is still allowed to resolve its package graph. The compiled build that CodeQL analyzes must occur between initialization and analysis.^4^

    Diagnose the lookup under the tracer

    The matching Developer Community report describes the same failure pattern: CodeQL relocates/intercepts swiftc, SwiftPM derives a toolchain location from that compiler, and sibling clang lookup then fails in the copy root.^5^ Your observations are consistent with that mechanism, but the missing copy-root clang entry alone does not prove it; the tracer log is needed.

    Add an Agent job → Command line task after the archive with Run this task: Even if a previous task has failed, using:

    set -u
    echo "CodeQL-related environment:"
    env | sort | grep -E '^(SEMMLE|CODEQL|DEVELOPER_DIR|TOOLCHAINS)=' || true
    
    echo "Compiler resolution:"
    xcrun --find swiftc || true
    xcrun --find clang || true
    
    echo "Tracer and database logs:"
    find "$AGENT_TEMPDIRECTORY" -type f \
      \( -name 'build-tracer.log' -o -name '*.log' \) \
      -path '*advancedsecurity.codeql*' -print 2>/dev/null || true
    

    Do not dump complete environment values or source/database contents into public logs. CodeQL diagnostic artifacts can contain sensitive information, including analyzed source content.

    For the run itself, set the Classic pipeline variable system.debug to true. Azure Pipelines documents this as the switch for verbose task and agent diagnostics.^6^

    Upload the located build-tracer.log as a secure pipeline artifact or support attachment. Azure Pipelines supports uploading individual custom logs with ##vso[task.uploadfile] or directories with PublishPipelineArtifact@1.^6^

    Supported remediation and escalation

    If the newest automatically installed bundle still fails:

    • Do not create clang or SDK-header symlinks in SEMMLE_COPY_EXECUTABLES_ROOT; your Darwin-module failure shows that this creates an incomplete relocated toolchain rather than a supported repair.
    • Do not repeat the SwiftPM cache or cloned-package-directory changes; those have already ruled out package-cache state.
    • If operationally possible, use an older Xcode version that is supported by the installed CodeQL bundle as a temporary workaround. This is a compatibility isolation step, not evidence that Xcode itself is defective.
    • Open a Microsoft Azure DevOps support case and attach:
      • pipeline run URL and hosted image;
      • Xcode version/build;
      • CodeQL CLI/bundle and task versions;
      • system.debug logs;
      • build-tracer.log;
      • the pre-/post-init compiler paths and copy-root listing;
      • confirmation that the identical archive succeeds without CodeQL.

    The exact Xcode 26.3 Azure Pipelines report was closed upstream because the Azure DevOps integration is maintained by Microsoft rather than by github/codeql-action.[^7^](https://github.com/github/codeql-action/issues/4279 "#4279 Azure Pipelines: Xcode 26.3 fails to resolve SwiftPM dependencies with unableToFind(tool: "clang") after CodeQL initialization")


    References

    1. Set up code scanning
    2. Xcode 26 support? · Issue #20669 · github/codeql
    3. AdvancedSecurity-Codeql-Init@1 - Advanced Security Initialize CodeQL v1 ...
    4. Troubleshoot code scanning for GitHub Advanced Security for Azure ...
    5. CodeQL (Advanced Security) Swift build tracing fails with unableToFind ...
    6. Review logs to diagnose pipeline issues
    7. #4279 Azure Pipelines: Xcode 26.3 fails to resolve SwiftPM dependencies with unableToFind(tool: "clang") after CodeQL initialization
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.