配置 EAS 元数据

编辑页面

了解配置 EAS 元数据的不同方式。


For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.

重要 EAS 元数据 处于 beta 阶段,且可能会发生破坏性变更。

EAS 元数据通过位于项目 根目录store.config.json 文件进行配置。

你可以使用 eas.jsonmetadataPath 属性来配置商店配置文件的路径或名称。 除了默认的 JSON 格式外,EAS 元数据还支持使用 JavaScript 文件来提供更动态的配置。

静态商店配置

EAS 元数据的默认商店配置类型是一个简单的 JSON 文件。 下面的代码片段展示了一个示例商店配置,其中包含用英文(美国)编写的基础 App Store 信息。

你可以在 store config schema 中找到所有配置选项。

如果你安装了 VS Code Expo Tools 扩展,你会在 store.config.json 文件中获得自动补全、建议和警告。

store.config.json
{ "configVersion": 0, "apple": { "info": { "en-US": { "title": "Awesome App", "subtitle": "Your self-made awesome app", "description": "The most awesome app you have ever seen", "keywords": ["awesome", "app"], "marketingUrl": "https://example.com/en/promo", "supportUrl": "https://example.com/en/support", "privacyPolicyUrl": "https://example.com/en/privacy" } } } }

动态商店配置

有时,元数据属性可以受益于动态值。例如,元数据的 版权声明 应该包含当前年份。这可以通过 EAS 元数据自动完成。

要动态生成内容,首先创建一个 JavaScript 配置文件 store.config.js。然后,在 eas.json 文件中使用 metadataPath 属性来选择该 JS 配置文件。

eas metadata:pull 不能更新动态商店配置文件。相反,它会创建一个与所配置文件同名的 JSON 文件。你可以导入该 JSON 文件,以复用 eas metadata:pull 的数据。

store.config.js
// 使用来自 `eas metadata:pull` 的数据 const config = require('./store.config.json'); const year = new Date().getFullYear(); config.apple.copyright = `${year} Acme, Inc.`; module.exports = config;
eas.json
{ "submit": { "production": { "ios": { "metadataPath": "./store.config.js" } } } }

使用外部内容的商店配置

在使用外部服务进行本地化时,你必须获取外部内容。 EAS 元数据支持从动态商店配置文件中导出同步和异步函数。 在验证并与商店同步之前,会先等待这些函数的结果。

store.config.js 函数会在 Node.js 中执行。如果你需要特殊值,比如密钥,请使用环境变量。

store.config.js
// 使用来自 `eas metadata:pull` 的数据 const config = require('./store.config.json'); module.exports = async () => { const year = new Date().getFullYear(); const info = await fetchLocalizations('...').then(response => response.json()); config.apple.copyright = `${year} Acme, Inc.`; config.apple.info = info; return config; };
eas.json
{ "submit": { "production": { "ios": { "metadataPath": "./store.config.js" } } } }