【问题标题】:Settings schema 'com.github.Suzie97.epoch' is not installed未安装设置架构“com.github.Suzie97.epoch”
【发布时间】:2021-03-29 09:40:04
【问题描述】:

这是我的应用程序的 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])

为什么会这样?

【问题讨论】:

    标签: settings glib meson-build


    【解决方案1】:

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

    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 会警告您未安装架构的原因:您缺少最后一个编译步骤。

    【讨论】:

    • 你好,我是编程新手,不太清楚你提到的几点。我尝试按照您在第 1 点中所说的那样重命名文件,但这没有用。当我删除在安装时重命名文件的行时,构建停止工作。至于第三点,我写了一个 post_install.py 脚本,但是还是不行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2017-12-25
    • 1970-01-01
    • 2016-07-01
    • 1970-01-01
    • 2015-02-14
    • 1970-01-01
    相关资源
    最近更新 更多