简体   繁体   English

Flutter/iOS:如何在 NotificationServiceExtension Info.plist 文件中使用 pubspec.yaml 的 App 版本?

[英]Flutter/iOS: How can I use pubspec.yaml's App version in my NotificationServiceExtension Info.plist file?

The Flutter App version from pubspec.yaml can be used in the regular iOS Info.plist file by changing entries to来自 pubspec.yaml 的 Flutter 应用程序版本可以在常规 iOS Info.plist 文件中使用,方法是将条目更改为

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

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

However I have created a Notification Service Extension to enable FCM Rich Text Push Notifications which is working fine.但是,我创建了一个通知服务扩展来启用运行良好的 FCM 富文本推送通知。 But when I change the Info.plist values of this extension to the same like above, the App fails with the following build error:但是当我将此扩展的 Info.plist 值更改为与上面相同时,应用程序失败并出现以下构建错误:

Unable to install /Users/pa/development/FlutterApps/myApp/build/ios/iphonesimulator/Runner.app on <ID>. This is sometimes caused by a malformed plist file:
ProcessException: Process exited abnormally:
An error was encountered processing the command (domain=IXErrorDomain, code=2):
Failed to create plugin placeholder for /Users/pa/development/FlutterApps/myApp/build/ios/iphonesimulator/Runner.app/PlugIns/NotificationService.appex
Failed to create promise.
Underlying error (domain=IXErrorDomain, code=2):
    Failed to set placeholder attributes com.mycompany.appid.NotificationService
    Failed to create promise.
  Command: xcrun simctl install <ID> /Users/pa/development/FlutterApps/myApp/build/ios/iphonesimulator/Runner.app
Error launching application on iPhone 11 Pro.

How can I use the same variables also in the Extensions Info.plist file?如何在 Extensions Info.plist 文件中使用相同的变量? I think it's just some config but I can't figure it out.我认为这只是一些配置,但我无法弄清楚。

Thanks!!谢谢!!

Flutter generates an xcconfig file with variables like FLUTTER_BUILD_NAME and FLUTTER_BUILD_NUMBER Flutter 生成一个xcconfig文件,其中包含FLUTTER_BUILD_NAMEFLUTTER_BUILD_NUMBER等变量

To use these variables in an extension we need to do the following:要在扩展中使用这些变量,我们需要执行以下操作:

  1. Go to your extension Info.plist and add those variables. Go 到您的扩展Info.plist并添加这些变量。像这样

Bundle version string -- $(FLUTTER_BUILD_NAME)捆绑版本字符串 -- $(FLUTTER_BUILD_NAME)

Bundle version -- $(FLUTTER_BUILD_NUMBER)捆绑版本 -- $(FLUTTER_BUILD_NUMBER)

  1. Go to your Project settings and select a Generated config file for your extension for each configuration. Go 到您的项目设置和 select 为每个配置的扩展Generated的配置文件。像这样

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 NSAppTransportSecurity 添加到我的 info.plist 文件中? - How can I add NSAppTransportSecurity to my info.plist file? 我可以在我的主机应用中阅读我的应用扩展程序的info.plist吗? - Can I read my app extension's info.plist in my host app? 如何在 info.plist 文件中使用 Code 值 xcode ios - How to use Code value in the info.plist file xcode ios 如何像在info.plist中一样在Settings.bundle中访问该应用程序的版本? - How can I access version of the app within Settings.bundle like it is in info.plist? iOS:如何在Info.plist的“打开方式”操作表中更改应用程序名称? - iOS: How can I change the app name in the Open-With action sheet in Info.plist? 如何在Info.plist中读取自定义键的值并在Xcode的构建设置中使用它? - How can I read a custom key's value in Info.plist and use it in Xcode's build settings? 如何配置我的目标以在Xcode中使用特定的Info.plist? - How can I configure my target to use a specific Info.plist in Xcode? Flutter ios 应用程序提交:Info.plist 中缺少目的字符串 - Flutter ios app submission: Missing Purpose String in Info.plist 应用程序因Info.plist文件麦克风中缺少目的字符串而被拒绝,但我无法在info.plist中添加说明 - App got rejected for missing Purpose String in Info.plist File Microphone, but I can't add the description in info.plist 如何国际化iOS公共plist资源文件而不是“ info.plist”? - How to internationalize iOS common plist resource file not “info.plist”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM