首页 > 解决方案 > 未安装设置架构“com.github.Suzie97.epoch”

问题描述

这是我的应用程序的 gschema.xml 代码:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
    <schema path="/com/github/Suzie97/epoch"
    id="com.github.Suzie97.epoch"
    gettext-domain - "com.github.Suzie97.epoch">
        <key name="pos-x" type="i">
            <default>360</default>
            <summary>Most recent x position of Epoch</summary>
            <description>Most recent x position of Epoch</description>
        </key>
        
        <key name="pos-y" type="i">
            <default>360</default>
            <summary>Most recent y position of Epoch</summary>
            <description>Most recent y position of Epoch</description>
        </key>
    </schema>
</schemalist>

这是安装 gschema 的 meson.build 文件:

install_data(
    'gschema.xml',
    install_dir: join_paths (get_option ('datadir'), 'glib-2.0', 'schemas'),
    rename: meson.project_name() + '.gschema.xml'
)

当我编译时显示此错误: Settings schema 'com.github.Suzie97.epoch' is not installed

这是 post_install.py 脚本:

#!/usr/bin/env python3

import os
import subprocess

install_prefix = os.environ['MESON_INSTALL_PREFIX']
schemadir = os.path.join(install_prefix, 'share/glib-2.0/schemas')
    
if not os.environ.get('DESTDIR'):
    print('Compiling the gsettings schemas ... ')
    subprocess.call(['glib-compile-schemas', schemadir])

为什么会这样?

标签: settingsglibmeson-build

解决方案


有各种各样的问题在起作用:

  1. 架构文件的名称应该与您的应用程序的标识符相匹配——在这种情况下,它将是com.github.Suzie97.epoch.gschema.xml
  2. 您不应该在安装时重命名文件;只需将其安装在glib-2.0/schemas数据目录下就足够了
  3. glib-compile-schemas $datadir/glib-2.0/schemas安装应用程序后,您应该调用“编译”所有模式;这通常作为 Meson 中的安装后脚本完成,使用meson.add_install_script().

GSettings本身不使用 XML :该glib-compile-schemas工具将生成一个缓存文件,该文件将由使用 GSettings 的所有应用程序共享,并且加载速度很快。这就是 GSettings 会警告您未安装架构的原因:您缺少最后一个编译步骤。


推荐阅读