Delphi 10.2 Tokyo运行时包XML文档注释失效问题咨询
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
Verify XML Files Are Generated in the Right Place
Open your runtime package's project options:- Go to
Compiler > Output - Confirm the
XML documentationcheckbox is ticked - Make sure
Output directoryandUnit output directoryare set to the same folder where your BPL is generated (e.g.,.\Win32\Release)
After recompiling the package, check that folder—you should see.xmlfiles matching your units (likeunit1.xml) alongside the BPL.
- Go to
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 toTools > Options > Language > Delphi > Library > Library Pathinstead, but per-project search path is cleaner for testing.
- Navigate to
Ensure DCP File Path is Configured
Runtime packages generate.dcpfiles (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'sLibrary Path.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




