You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Delphi 10.2 Tokyo运行时包XML文档注释失效问题咨询

Delphi 10.2 Tokyo: XML Documentation Comments Missing in External Apps Using Runtime Packages

This is a common gotcha with Delphi runtime packages and XML doc comments—let's break down why this happens and how to fix it:

Why the Comments Disappear

Delphi doesn't embed XML documentation directly into BPL files. Instead, it generates separate .xml files for each unit (and sometimes a package-level XML) during compilation. For your external VCL project to see these comments, its Code Insight engine needs to locate those XML files, which won't happen automatically unless you configure the paths correctly.

Step-by-Step Fixes

  1. Verify XML Files Are Generated in the Right Place
    Open your runtime package's project options:

    • Go to Compiler > Output
    • Confirm the XML documentation checkbox is ticked
    • Make sure Output directory and Unit output directory are set to the same folder where your BPL is generated (e.g., .\Win32\Release)
      After recompiling the package, check that folder—you should see .xml files matching your units (like unit1.xml) alongside the BPL.
  2. Add the XML Path to Your External Project's Search Path
    Open your test VCL project's options:

    • Navigate to Delphi Compiler > Search Path
    • Add the full path to the folder containing your package's XML files
      Pro tip: If you want this path available to all your projects, you can add it to Tools > Options > Language > Delphi > Library > Library Path instead, but per-project search path is cleaner for testing.
  3. Ensure DCP File Path is Configured
    Runtime packages generate .dcp files (Delphi Compiled Package) that hold metadata about the package's units. Your external project needs to find this file to link up with the XML comments. Make sure the DCP's folder (usually same as BPL/XML) is in your external project's Library Path.

  4. Clear IDE Cache and Recompile
    Delphi's Code Insight can sometimes cache old data. Restart your IDE, first recompile the runtime package, then recompile the external project. This forces the IDE to re-scan for the latest XML files.

Quick Validation Check

In your external project, hold Ctrl and click on the TDemo class—if the IDE jumps to the unit in your runtime package, your path setup is mostly correct. If the comments still don't show, double-check that the unit1.xml exists in the path you added, and that the XML content matches the comments in your unit.

内容的提问来源于stack exchange,提问作者fisi-pjm

火山引擎 最新活动