[英]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_NAME
和FLUTTER_BUILD_NUMBER
等变量
To use these variables in an extension we need to do the following:要在扩展中使用这些变量,我们需要执行以下操作:
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)
Generated
config file for your extension for each configuration. Go 到您的项目设置和 select 为每个配置的扩展Generated
的配置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.