【问题标题】:Missing CFBundleShortVersionString when distribute Flutter app with ShareExtension使用 ShareExtension 分发 Flutter 应用程序时缺少 CFBundleShortVersionString
【发布时间】:2020-12-16 05:32:11
【问题描述】:

我有一个使用 receive_sharing_intent 包的 Flutter 应用程序,并且根据插件的要求,我创建了一个共享扩展。

我的应用程序和扩展程序构建和工作正常,但是当我存档和分发我的应用程序 (App Store Connect) 时,在上传结束时我收到以下错误消息:

错误 ITMS-90057:“捆绑包 'Payload/Runner.app/PlugIns/ShareExtension.appex' 缺少 plist 键。Info.plist 缺少所需的键:CFBundleShortVersionString。”

错误 ITMS-90056:“此捆绑包 'Payload/Runner.app/PlugIns/ShareExtension.appex' 无效。Info.plist 缺少所需的密钥:CFBundleVersion。”

错误 ITMS-90360:“缺少 Info.plist 值。捆绑 Payload/Runner.app/PlugIns/ShareExtension.appex 中键 'CFBundleVersion' 的值是必需的。”

错误 ITMS-90360:“缺少 Info.plist 值。捆绑 Payload/Runner.app/PlugIns/ShareExtension.appex 中的键 'CFBundleShortVersionString' 的值是必需的。”

但在我的ios/ShareExtension/Info.plist 文件中,我有:

    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>

我也尝试过:

    <key>CFBundleShortVersionString</key>
    <string>$(MARKETING_VERSION)</string>
    <key>CFBundleVersion</key>
    <string>$(CURRENT_PROJECT_VERSION)</string>

删除了CFBundleVersion 的错误,但CFBundleShortVersionString 仍然无效。

通过在扩展 plist 中明确设置我的应用版本和内部版本号,上传成功。
但是有没有办法在扩展plist中使用FLUTTER_BUILD_NAMEFLUTTER_BUILD_NUMBER变量?

注意:

我使用的是 Xcode 11.6

【问题讨论】:

  • 您找到解决方案了吗?
  • 还没有,作为一种解决方法,我在 plist 文件中为我的构建手动设置版本字符串...
  • 这里也一样。编写了一个简短的 C 程序,我在构建期间调用它并将这些值替换为来自 pubspec.yaml 的适当版本号。
  • @YanivShaked 你介意分享那个 C 程序吗?我也有这个问题。
  • @AidanDavis,我已经发布了 C 程序源代码以及我目前在构建过程中使用的 ZSH 脚本作为这个问题的答案(见下文)

标签: ios xcode flutter


【解决方案1】:

根据@Aidan David 的要求分享我的 C 程序,但是:

  • 我认为这不是正确的解决方案,而只是一种解决方法。
  • 使用风险自负 :-)
  • 还添加了我用来注入所需 plist 值的 zsh 脚本。

ZSH 脚本:

./plist_replace_value ./NotificationService/Info.plist CFBundleVersion `grep ^version: ../pubspec.yaml | awk -F'[\+ ]' '{print $3}'`
./plist_replace_value ./NotificationService/Info.plist CFBundleShortVersionString `grep ^version: ../pubspec.yaml | awk -F'[\+ ]' '{print $2}'`
./plist_replace_value ./Share\ Extension/Info.plist CFBundleVersion `grep ^version: ../pubspec.yaml | awk -F'[\+ ]' '{print $3}'`
./plist_replace_value ./Share\ Extension/Info.plist CFBundleShortVersionString `grep ^version: ../pubspec.yaml | awk -F'[\+ ]' '{print $2}'`

C 程序,plist_replace_value.c:

#include <string.h>
#include <stdio.h>

#define MAX_LINE 256

void print_usage(char *programName)
{
    printf("\nUsage:\n%s <plist file> <key> <value>\n", programName);
}

int main(int argc, char *argv[])
{
    FILE *plist_file, *output_file;
    int replaced = 0;
    char line[MAX_LINE];
    printf("Plist key-value parser. Supports replacing values.\n");
    fflush(stdout);
    if (argc < 4)
    {
        fprintf(stderr, "Insufficient number of parameters.");
        print_usage(argv[0]);
        return 1;
    }
    
    plist_file = fopen(argv[1], "r+");
    if (plist_file == NULL)
    {
        fprintf(stderr, "Unable to open %s, aborting...\n", argv[1]);
        return 1;
    }

    output_file = fopen("temp.plist", "w");
    if (output_file == NULL)
    {
        fprintf(stderr, "Unable to create temporary file, aborting...\n");
        return 1;
    }

    fgets(line, MAX_LINE, plist_file);
    while (!feof(plist_file) && !replaced)
    {
        fprintf(output_file, "%s", line);
        if (strstr(line, argv[2]) != NULL)
        {
            fprintf(output_file, "\t<string>%s</string>\n", argv[3]);
            // Skip the next output line
            fgets(line, MAX_LINE, plist_file);
        }
        fgets(line, MAX_LINE, plist_file);
    }

    fclose(output_file);
    fclose(plist_file);
    remove(argv[1]);
    rename("temp.plist", argv[1]);

    return 0;
}

【讨论】:

    【解决方案2】:

    当应用版本没有版本代码时,我遇到了同样的问题。对于 1.0.0 之类的版本,ios 应用缺少 plist 键错误。尝试添加 1.0.0+0

    之类的版本代码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-27
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2011-02-16
      • 2015-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多