如果存在 install.rdf,为什么附加图标会消失?

Why does add-on icon disappear, if install.rdf is present?

安装附加组件后,我在 Firefox 中看不到工具栏图标。 我在开发过程中遇到过这个问题。如果存在 install.rdf 文件,则附加组件的图标不会出现在 Firefox 工具栏中。然而,它在没有 install.rdf 文件的情况下工作得很好。怎么了?

<?xml version="1.0" encoding="UTF-8"?>

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  <Description about="urn:mozilla:install-manifest">
    <em:id>extensionName@myDomain.com</em:id>
    <em:version>1.23</em:version>
    <em:type>2</em:type>

    <em:targetApplication>
      <Description>
        <em:id>{uuid here}</em:id>
        <em:minVersion>31.*</em:minVersion>
        <em:maxVersion>47.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <em:name>extensionName</em:name>
    <em:description>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veniam voluptates natus soluta quis culpa animi, vitae laborum magnam! Facere reiciendis nihil porro non odio hic deserunt obcaecati soluta, nostrum recusandae!</em:description>
    <em:creator>Name LastName</em:creator>
    <em:homepageURL>http://www.mydDomain.com/</em:homepageURL>
  </Description>
</RDF>

此答案基于关于您的附加组件的一些假设。在问题中包含 Minimal, Complete, and Verifiable Example (MCVE) 对您很有帮助,这样我们就可以重现问题。如果没有 MCVE,则有必要猜测您的问题到底是什么。

您的扩展 "works"(或至少在 Firefox 工具栏中显示一个图标)没有 install.rdf 文件这一事实表明您正在使用附加 SDK。此答案基于您使用附加 SDK 的假设。如果您没有使用附加 SDK,那么在没有 install.rdf 文件的情况下附加组件根本无法工作,我们需要一个 MCVE 。作为构建过程的一部分,附加 SDK 会自动生成 install.rdf

我建议查看在构建过程中生成的 install.rdf 并复制它。然后,如果您有想要调整的内容,您可以对该文件进行更改。

至于您当前使用的install.rdf文件,您可能至少需要添加:

<em:bootstrap>true</em:bootstrap>

这可能是需要的,因为所有附加 SDK 扩展都是无需重新启动的。但是,最好的办法是使用自动生成的 install.rdf 并只更改您需要的内容。