ios - 使用 ShareExtension 分发 Flutter 应用程序时缺少 CFBundl

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

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

ERROR ITMS-90057: "The bundle 'Payload/Runner.app/PlugIns/ShareExtension.appex' is missing plist key. The Info.plist is missing the required key: CFBundleShortVersionString."

ERROR ITMS-90056: "This bundle 'Payload/Runner.app/PlugIns/ShareExtension.appex' is invalid. The Info.plist is missing the required key: CFBundleVersion."

ERROR ITMS-90360: "Missing Info.plist value. A value for the key 'CFBundleVersion' in bundle Payload/Runner.app/PlugIns/ShareExtension.appex is required."

ERROR ITMS-90360: "Missing Info.plist value. A value for the key 'CFBundleShortVersionString' in bundle Payload/Runner.app/PlugIns/ShareExtension.appex is required."

但是在我的 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

最佳答案

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

  • 我认为这不是正确的解决方案,而只是一种解决方法。
  • 使用风险自负:-)
  • 同时添加我用来注入(inject)所需 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 
#include 

#define MAX_LINE 256

void print_usage(char *程序名)
{
    printf("\nUsage:\n%s   \n", programName);
}

int main(int argc, char *argv[])
{
    文件 *plist_file, *output_file;
    int 替换 = 0;
    字符线[MAX_LINE];
    printf("Plist 键值解析器。支持替换值。\n");
    fflush(标准输出);
    如果(argc %s\n", argv[3]);
           //跳过下一个输出行
            fgets(线,MAX_LINE,plist_file);
        }
        fgets(线,MAX_LINE,plist_file);
    }

    fclose(输出文件);
    fclose(plist_file);
    移除(argv[1]);
    重命名(“temp.plist”,argv [1]);

    返回 0;
}

关于ios - 使用 ShareExtension 分发 Flutter 应用程序时缺少 CFBundleShortVersionString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63614181/

相关文章:

javascript - 如果导航到 React Native 中的其他屏幕,如何保留 formik

python - (-212 :Parsing error) in Object Detection

html - CSS Grid - 在自动流列上自动生成新的行中断

markdown - 如何在 Sublime Text 3 中为 Markdown 启用 Emmet

java - 致命异常 : java. lang.IllegalArgumentException

apache-flink - Apache Flink JobListener 无法正常工作

mongodb - Azure cosmosDB : Getting error on sortin

python-attrs - attrs转换器的装饰器

php - 如何使用 line bot webhook 请求在线路组中使用 @mention/@ta

javascript - Greasemonkey 用户脚本被内容安全策略阻止